Skip to content

Instantly share code, notes, and snippets.

@abhiramsingh
Last active December 14, 2015 10:49
Show Gist options
  • Save abhiramsingh/5074647 to your computer and use it in GitHub Desktop.
Save abhiramsingh/5074647 to your computer and use it in GitHub Desktop.
Test Harness for Heap.java
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