MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / pop

Method pop

src/class027/Code02_MaxCover.java:82–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80 }
81
82 public static void pop() {
83 swap(0, --size);
84 int i = 0, l = 1;
85 while (l < size) {
86 int best = l + 1 < size && heap[l + 1] < heap[l] ? l + 1 : l;
87 best = heap[best] < heap[i] ? best : i;
88 if (best == i) {
89 break;
90 }
91 swap(i, best);
92 i = best;
93 l = i * 2 + 1;
94 }
95 }
96
97 public static void swap(int i, int j) {
98 int tmp = heap[i];

Callers 1

computeMethod · 0.95

Calls 1

swapMethod · 0.95

Tested by

no test coverage detected