# Heaps and Tries

An emergency room's most-urgent-first waiting list, built as a heap and used as your language's priority queue; then the trie, which lets a phone suggest the next word.

Updated: November 17, 2026

## [Heaps](https://www.ask-codey.com/courses/data-structures/topics/ds-heaps)

1. [Who's Next in the Emergency Room? Heaps](https://www.ask-codey.com/lessons/ds-heaps) (Journeyman): Always call the most urgent patient next while new ones keep arriving, even on a day of 10,000: why an unsorted list and a sorted list both slow down, and the structure that fixes them, the heap, which keeps a tree in a plain array.
2. [Fair Ties, Ready-Made: Priority Queues in Your Language](https://www.ask-codey.com/lessons/ds-priority-queues) (Journeyman): See the most urgent patient first and, of two equally urgent, the one who has waited longer, with the priority queue your language already has (PriorityQueue in C# and Java, heapq in Python) or a small one in JavaScript and TypeScript, which have none.

## [Tries](https://www.ask-codey.com/courses/data-structures/topics/ds-tries)

1. [How a Phone Suggests the Next Word: Tries](https://www.ask-codey.com/lessons/ds-tries) (Journeyman): Suggest words from a 100,000-word dictionary on every keypress, and learn new words as they're typed: why checking every word, a hash set and a sorted array each fall short, and the structure that fixes them, the trie.

## [Exercise: Emergency Room Triage](https://www.ask-codey.com/courses/data-structures/topics/exercise-ds-er-triage)

1. [Exercise: Emergency Room Triage](https://www.ask-codey.com/lessons/exercise-ds-er-triage) (Journeyman): Build an emergency room's waiting list: most urgent first, fair ties, arrivals and calls all night, and a 100,000-patient disaster drill in under 3 seconds; then see what the same structure does for Module 7's maps and routes.

Source: https://www.ask-codey.com/courses/data-structures/chapters/ds-heaps-and-tries
