There are two types of heaps. First one is Max heap and second one is Min heap. Heap (Max/Min) is a special type of binary tree.The roots of the max heap is greater than its child roots. Other heap is Min heap it is also a special type of heap which has minimum root than his child. We can sort the array values using heap sorting algorithm. In this algorithm the heap build is used to rebuild the heap.
Showing posts with label java code. Show all posts
Showing posts with label java code. Show all posts
9/24/11
9/1/11
SortableStack implementation in Java
I am implementing an interface for Stack which will help to push and pop in O(n) time and help in finding the highest, lowest and the middle element in O(1) time.
I will be using Arraylist (since I m using a standard jdk 6 and not some other package) because with using this we can implement the above interface in the least possible time.
I will be using Arraylist (since I m using a standard jdk 6 and not some other package) because with using this we can implement the above interface in the least possible time.