Skip to content

Commit 36a5126

Browse files
committed
Using and explaining pq nomenclature in regards to heaps
1 parent a00aed3 commit 36a5126

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

docs/computer-science.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@ Queues are a list of values sorted by entry time. A FIFO (first in first out) sy
186186

187187
A priority queue is like a [queue](#queue), only you can specify the priority for an element when you add it, and you can modify the priority of an element that's in the queue.
188188

189+
You may see some sources that use a *fibbonacci heap* or a *binary heap*. These are actually just priority queues. The heap is just how the priority queue is stored and operated with on a lower level.
190+
191+
!!! note "Explanation on heaps"
192+
193+
This is not in the study design. This is just if you're interested and want to see a very common use case for trees
194+
195+
<iframe width="560" height="315" src="https://www.youtube.com/embed/E2v9hBgG6gE?si=yqJ2RpLYKEDOxLeK" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
196+
197+
198+
189199
###### Minimum priority queue
190200

191201
When the highest priority item is measured by the lowest weight

docs/graphs.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -849,13 +849,12 @@ Finds the shortest **greedy** path via a **[priority queue](computer-science.md#
849849

850850
<img src="images/Dijkstra_Animation.gif" alt="Dijkstra_Animation">
851851

852-
Worst case performance:
852+
Worst case performance if using a [priority queue](computer-science.md#priority-queue):
853+
$$\displaystyle O(|E|+|V|\log |V|)$$
853854

855+
Worst case performance when using an array:
854856
$$\displaystyle O(|V^2|)$$
855857

856-
Worst case performance if using a **Fibonacci heap** (non-trivial):
857-
$$\displaystyle O(|E|+|V|\log |V|)$$
858-
859858
- Finds shortest path from starting node, to any other location, not just the desired location.
860859
- Works on weighted, weighted graphs and weighted digraphs. **Where no negative weight cycles exist**
861860

0 commit comments

Comments
 (0)