Understanding the problem
To better understand a heap, let us look at some interesting problems programmers face when designing software systems. When writing a program, we often need a data store that is smart enough to remember the smallest or largest data items stored in it at all times. Inserting new data items and retrieving the new minimum or maximum should be very efficient.
For example, consider a hospital emergency ward with only a few doctors but multiple patients. Each patient is assigned a number to determine their priority, depending on how critical their situation is. Whenever a doctor becomes available, the patient with the highest priority is picked up from the room, and the doctor is assigned to them.
Patients assigned priorities to see a fixed number of doctors
Liking the course? Check our discounted plans to continue learning.