Skip to content

Commit

Permalink
Added heap definition and example (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
Elstuhn committed Oct 2, 2022
1 parent 25c6b76 commit bc6e179
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Data Structures/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,17 @@ Let hash function H(x) = [11,12,13,14,15]
// it will be stored at positions {1,2,3,4,5}
// in the array or Hash table respectively.
```
[More on Hash Table](HashTable.md)
[More on Hash Table](HashTable.md)

## Heap

A heap is a specialized tree-based data structure which is an almost complete tree that satisfies the heap property. The heap property means that the element with the greatest key is always in the root node such a heap is sometimes called a max-heap.

### Example

```
Let array of numbers be [100, 7, 2, 17, 3, 25, 1, 36, 19]
// It will be in a tree-like form where the largest number will point to a smaller number and the smaller number points to an even smaller number and so on
```
![Heap example](https://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/Max-Heap-new.svg/1200px-Max-Heap-new.svg.png)
[More on Heap](Heap.md)

0 comments on commit bc6e179

Please sign in to comment.