Skip to content

Commit 2a6a62d

Browse files
committed
fix heap cheatsheet, templeate, add pq cheatsheet
1 parent eb7ef40 commit 2a6a62d

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

doc/cheatsheet/00_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# cheatsheet template
22

3-
## 0) Concept
3+
## 0) Concept
44

55
### 0-1) Types
66

doc/cheatsheet/heap.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
- https://leetcode.com/explore/learn/card/heap/
77
- 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`.
88

9-
- Priority Queue
9+
- Priority Queue (PQ)
10+
- Priority queue is one of the imeplementations of heap
1011
- a priority queue is an `abstract data type` similar to a regular queue or stack data structure in which each element additionally has a `"priority"` associated with it. In a priority queue, an element with high priority is served before an element with low priority.
1112
- `Heap != Priority Queue`
1213
- Priority Queue is a abstract data type
@@ -21,12 +22,14 @@
2122
- The maximum/minimum value in the Heap can be obtained with `O(1)` time complexity.
2223
<p align="center"><img src ="https://github.com/yennanliu/CS_basics/blob/master/doc/pic/type_of_heap.png" ></p>
2324

24-
- Definition : given a tree, if P is C's parent node -> P always `<=` or `>=` C.
25+
- Definition : if P parent node, C is child node -> P always `<=` or `>=` C.
2526
- Types
2627
- min heap
27-
- given a tree, if P is C's parent node -> P always `<=` C.
28+
- if P parent node, C is child node -> P always <= C
29+
- 父節點總是 <= 子節點的值 (不需 右子節點 <= 父節點 <= 左子節點)
2830
- max heap
29-
- given a tree, if P is C's parent node -> P always `>=` C.
31+
- if P parent node, C is child node -> P always >= C
32+
- 父節點總是 >= 子節點的值 (不需 右子節點 <= 父節點 <= 左子節點)
3033
- was invented for `heap sort`
3134
- a heap is a specialized tree-based data structure which is essentially an almost completed tree that satisfies the heap property:
3235
- In a max heap
@@ -51,7 +54,9 @@
5154
### 1-0) Basic OP
5255

5356
- V1
54-
- build
57+
- build heap
58+
- upHeap
59+
- downHeap
5560
- insert
5661
- update
5762
- get

doc/cheatsheet/priority_queue.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Priority Queue (PQ)
2+
3+
## 0) Concept
4+
5+
- Priority queue is one of the imeplementations of heap
6+
7+
### 0-1) Types
8+
9+
### 0-2) Pattern
10+
11+
## 1) General form
12+
13+
### 1-1) Basic OP
14+
15+
## 2) LC Example

0 commit comments

Comments
 (0)