Heaps

Heaps: Who's Next in the Emergency Room? Heaps, Fair Ties, Ready-Made: Priority Queues in Your Language.

Updated

  1. Who's Next in the Emergency Room? 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 (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.