Skip to content

Commit 5ae6583

Browse files
add Real-World Example to Heaps
1 parent d613c86 commit 5ae6583

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Cheatsheet/Heaps/heaps.md

+6
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ A heap is a data structure that organizes elements based on priority, ensuring t
2121
## Priority queue
2222

2323
A priority queue is a special type of heap that follows the structure of min-heaps or max-heaps but allows customization in how elements are prioritized (e.g. prioritizing strings with a higher number of vowels.)
24+
25+
---
26+
27+
### Real-World Example
28+
29+
**Managing tasks in operating systems:** Operating systems often use a priority queue to manage the execution of tasks, and a heap is commonly used to implement this priority queue efficiently. For example, when multiple processes are running on a computer, each process might be assigned a priority level. The operating system needs to schedule the processes so that higher-priority tasks are executed before lower-priority ones. A heap is ideal for this because it allows the system to quickly access the highest-priority task and efficiently re-arrange the priorities as new tasks are added or existing tasks are completed.

0 commit comments

Comments
 (0)