Optimizing Task Scheduling From On2 To Onlogn Using Heaps