Skip to content

Commit

Permalink
update cheatsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed May 13, 2024
1 parent 7a5ea4e commit 67deeb1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions doc/cheatsheet/heap.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Intro
- https://leetcode.com/explore/learn/card/heap/
- In many CS applications, we only need to `access the largest or smallest element` in the dataset. We DO NOT care about `the order of other data in the data set`. How do we efficiently access the largest or smallest element in the current dataset? The answer would be `Heap`.
- heap is a "complete binary tree"

- Priority Queue (PQ)
- Priority queue is one of the implementations of heap
Expand Down Expand Up @@ -73,6 +74,14 @@
- Get the length of a Heap.
- Perform time and space complexity analysis for common applications that use a Heap.

- V3
- up heap
- (new big element added to max heap, move it to root)
- down heap
- (new samll element added to max heap, move it to sub tree)
- build heap
- PQ

### 1-1) heapq (`heap queue` AKA `priority queue`) (Py api)
- Note :
- in Py, heapq is `MIN heap`
Expand Down

0 comments on commit 67deeb1

Please sign in to comment.