The busy driver in the heap
transcript
Four drivers are near a pickup. Driver one is busy. Two drivers get the offer. Which two?
Driver zero is two blocks away. Driver one is four blocks away, but busy. Driver two is five blocks away.
Filter first, and the offer goes to zero and two. Skip it, and driver one gets an offer. A busy driver cannot take the ride.
A city has thousands of drivers. Each request needs a short list. A heap of k keeps it short.
Filter to the free drivers. Then keep the best k in a heap. Break ties by driver number.
The heap keeps only the best k. A busy driver takes a place. A free driver is pushed out.
Test with one busy driver. Make it the closest of all. The answer must skip it.
Two free drivers can tie. Use the statement's rule. Never rely on heap order.
A busy driver never enters the heap. Full breakdown in the lecture.