Monday, June 23, 2014

Heaps (Max-Min)

Hello Everyone,

Midst the Algorithms class this Summer, we were being taught some efficient Data Structures in terms of handling large Data. One of them was Heaps which is a very interesting one. Our Professor  Zhifeng Sun told us that there are less libraries for Heaps and hence inspired me to right one with almost all the supported operations by Heaps. Though I look forward to improve the library, some applications I found were such as finding a winner among many people and this application can be extended over many other similar applications. With Heaps you can achieve this O(1) time i.e. constant time. It also appeared interesting to me as when working with Multi-Platform mobile applications we generally see that the application takes time to process even 100 records in an array and our aim is to find a single record which satisfies our needs. Heaps can effectively reduce that time from O(n) to O(logn). Though this library for now works only for integers, I am thinking to extend it to <AnyType>. Below is the list of operations supported by the library:

/* Heap Operations
1) DeleteMax/ExtractMax: ------ Running Time: O(logn)
2) Query Max/Min: ------- Running Time: O(1)
3) InsertElement: ----- Running Time: O(logn)
4) Heapify: ----- Running Time: O(logn)
5) Build Heap: ------ Running Time: O(nlogn)
6) Find K Min/Max Elements: ------ Running Time: O(klogn)
*/


The library supports operations for both the Max-Heap and Min-Heap. Below is the github
URL from which you will get a thorough understanding and it can be used as a
plugin/module for PhoneGap & Titanium applications though it might need some additional
work.

https://github.com/vishalrajpal/TestHeap

I look forward for your suggestions on improving it.

Thanks,
Vishal