Last active
December 14, 2015 10:49
-
-
Save abhiramsingh/5074647 to your computer and use it in GitHub Desktop.
Test Harness for Heap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.abhi.ds.heap; | |
public class HeapTestHarness { | |
public static void main(String a[]) { | |
Heap<Integer> hp = new Heap<Integer>(); | |
hp.addItem(5); | |
hp.addItem(3); | |
hp.addItem(2); | |
hp.addItem(9); | |
hp.addItem(11); | |
System.out.println("List backed data structure to demonstrate Heap and Heap Sort Algorithm: "+hp); | |
if (!hp.isEmpty()) { | |
hp.sort(); | |
System.out.println("Sorted Heap: "+hp); | |
hp.insert(12); | |
System.out.println("Insertion of new element(12) in the heap: "+hp); | |
hp.delete(); | |
System.out.println("Deletion from the heap(top node): "+hp); | |
hp.sort(); | |
System.out.println("Heap Sort Again: "+hp); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment