Skip to content

Commit 509d997

Browse files
committed
MinHeapExample | basic code
1 parent aacd909 commit 509d997

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package CollectionsFramework.Day_5;
2+
3+
import java.util.PriorityQueue;
4+
5+
public class MinHeapExample {
6+
7+
public static void main(String[] args) {
8+
PriorityQueue<Integer> minHeap = new PriorityQueue<>();
9+
minHeap.add(40);
10+
minHeap.add(10);
11+
minHeap.add(30);
12+
13+
while (!minHeap.isEmpty()) {
14+
System.out.print(minHeap.poll() + " "); // 10, 30, 40
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)