Heap

General Idea:

https://www.cs.cmu.edu/~adamchik/15-121/lectures/Binary%20Heaps/heaps.html

Important Application:

The heap data structure has many applications:

  • Heapsort: One of the best sorting methods being in-place and with no quadratic worst-case scenarios.
  • Selection algorithms: A heap allows access to the min or max element in constant time, and other selections (such as median or kth-element) can be done in sub-linear time on data that is in a heap.[13]
  • Graph algorithms: By using heaps as internal traversal data structures, run time will be reduced by polynomial order. Examples of such problems are Prim's minimal-spanning-tree algorithm and Dijkstra's shortest-path algorithm.
  • Priority Queue: A priority queue is an abstract concept like "a list" or "a map"; just as a list can be implemented with a linked list or an array, a priority queue can be implemented with a heap or a variety of other methods.
  • Order statistics: The Heap data structure can be used to efficiently find the kth smallest (or largest) element in an array.

Leetcode Collection:

https://leetcode.com/tag/heap/

results matching ""

    No results matching ""