Skip to content

Files

Latest commit

1c0ce91 · Mar 27, 2018

History

History
This branch is up to date with Algorithm-archive/Learn-Data_Structure-Algorithm-by-Python:master.

README.md

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.

heap

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

  • Space - O(n)
  • Search - O(n)
  • Insertion - O(1)
  • Delete - O(log n) (Deletion from beginning)
  • Peek - O(1)

More on this topic