forked from techpanja/interviewproblems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestMaxHeap.java
More file actions
38 lines (35 loc) · 1.1 KB
/
TestMaxHeap.java
File metadata and controls
38 lines (35 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package heaps.test;
import heaps.heap.Heap;
import heaps.heap.MaxHeap;
/**
* Test class for max heap
* User: rpanjrath
* Date: 10/24/13
* Time: 2:51 PM
*/
public class TestMaxHeap {
public static void main(String[] args) {
Heap maxHeap = new MaxHeap(10);
maxHeap.insert(10);
maxHeap.insert(9);
maxHeap.insert(19);
maxHeap.insert(50);
maxHeap.insert(23);
maxHeap.insert(98);
maxHeap.displayHeap();
System.out.println();
System.out.println("Root or max of heap:-------- " + maxHeap.peek());
maxHeap.remove();
maxHeap.displayHeap();
System.out.println("Root or max of heap:-------- " + maxHeap.peek());
maxHeap.remove();
maxHeap.displayHeap();
System.out.println("Root or max of heap:-------- " + maxHeap.peek());
maxHeap.remove();
maxHeap.displayHeap();
System.out.println("Root or max of heap:-------- " + maxHeap.peek());
maxHeap.remove();
maxHeap.displayHeap();
System.out.println("Root or max of heap:-------- " + maxHeap.peek());
}
}