Skip to content

Heap code and test file added #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 27, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Heap README.md file add
  • Loading branch information
shaonty authored and shaonty committed Mar 25, 2018
commit c2d18dc9d94c4a0ffffbc23b54e98fd8d011184f
32 changes: 32 additions & 0 deletions Data Structure/Heap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Heap

A **Heap** is a tree based data structure and it is a complete binary tree which satisfies the heap ordering property. The ordering can be one of two types:

the **min-heap property:** the value of each node is greater than or equal to the value of its parent, with the minimum-value element at the root.
the **max-heap property:** the value of each node is less than or equal to the value of its parent, with the maximum-value element at the root.

**Basic Operations:**

Following are the basic operations supported by a list.

* **Insertion** − Adds an element at the max heap.

* **Deletion** − Deletes an element at the beginning of the heap.

* **Display** − Displays the complete heap.

* **Max** − Get the max element from the heap.


#### Complexity Analysis
Algorithm Average Worst case
Space O(n) O(n)
Search O(n) O(n)
Insert O(1) O(log n)
Delete O(log n) O(log n)
Peek O(1) O(1)

### More on this topic
- https://en.wikipedia.org/wiki/Heap_(data_structure)
- https://www.hackerearth.com/practice/data-structures/trees/heapspriority-queues/tutorial/
- https://www.geeksforgeeks.org/binary-heap/