Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
add the waiting list to the heap all at once?

hn200000

Aug 18, 2023

How do you ensure the same task is K distance away if you dump the waiting list to the heap all at once? e.g. - if all tasks in the waiting list have the same frequency, then the last task in the waiting list might happen to be at the root of the heap

0

0

Comments
Comments
Shubham Vora
Shubham Voraa year ago

When tasks with the same frequency are added back to the heap, they are not guaranteed to be spaced exactly k intervals apart. The approach ensures tasks are scheduled as soon as possible but does not enforce exact spacing for all identical tasks. If tasks have the sa...