MCPcopy
hub / github.com/kunal-kushwaha/DSA-Bootcamp-Java / downheap

Method downheap

lectures/24-heaps/code/heaps-1/Heap.java:59–76  ·  view source on GitHub ↗
(int index)

Source from the content-addressed store, hash-verified

57 return temp;
58 }
59 private void downheap(int index) {
60 int min = index;
61 int left = left(index);
62 int right = right(index);
63
64 if(left < list.size() && list.get(min).compareTo(list.get(left)) > 0) {
65 min = left;
66 }
67
68 if(right < list.size() && list.get(min).compareTo(list.get(right)) > 0) {
69 min = right;
70 }
71
72 if(min != index) {
73 swap(min, index);
74 downheap(min);
75 }
76 }
77
78 public ArrayList<T> heapSort() throws Exception {
79 ArrayList<T> data = new ArrayList<>();

Callers 1

removeMethod · 0.95

Calls 6

leftMethod · 0.95
rightMethod · 0.95
swapMethod · 0.95
sizeMethod · 0.45
compareToMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected