Skip to content

Latest commit

 

History

History
27 lines (14 loc) · 781 Bytes

README.md

File metadata and controls

27 lines (14 loc) · 781 Bytes

Heaps

  • A heap is a tree-based data structure in which all the nodes of the tree are in a specific order.

Representation

  • Max Heap: Stack but of k elements + Sorted + Topmost element is minima (base is filled with maximums)
  • Min Heap: Stack but of k elements + Sorted + Topmost element is maxima (base is filled with minimums)

Identification

Both condition must be there

  • mention of k elements
  • top / largest / smallest / least

Functions that can be performed on a heap

  • top() => get topmost element (max for minHeap and min for maxHeap)
  • push and pop operation but performed only on topmost elements

Problems

  1. Kth Largest/Smallest Element Problem Solution