MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / sort

Method sort

Misc/Heap_Sort/solution.java:44–63  ·  view source on GitHub ↗
(int arr[])

Source from the content-addressed store, hash-verified

42public class HeapSort
43{
44 public void sort(int arr[])
45 {
46 int n = arr.length;
47
48 // Build heap (rearrange array)
49 for (int i = n / 2 - 1; i >= 0; i--)
50 heapify(arr, n, i);
51
52 // One by one extract an element from heap
53 for (int i=n-1; i>0; i--)
54 {
55 // Move current root to end
56 int temp = arr[0];
57 arr[0] = arr[i];
58 arr[i] = temp;
59
60 // call max heapify on the reduced heap
61 heapify(arr, i, 0);
62 }
63 }
64
65 // To heapify a subtree rooted with node i which is
66 // an index in arr[]. n is size of heap

Callers 13

mainMethod · 0.95
solution.pyFile · 0.80
anagramsFunction · 0.80
solution.pyFile · 0.80
Solution.pyFile · 0.80
solution.pyFile · 0.80
SC_02.pyFile · 0.80
combinationSumMethod · 0.80
groupAnagramsMethod · 0.80
hotelFunction · 0.80
biggerIsGreaterMethod · 0.80
getMoneySpentFunction · 0.80

Calls 1

heapifyMethod · 0.95

Tested by

no test coverage detected