January 2018
Intermediate to advanced
332 pages
7h 36m
English
Let's first set up the data for testing the queue:
var priorityQueue = new PriorityQueue();priorityQueue.add({ el : 1, priority: 1});// state of Queue// [1]// ^priorityQueue.add({ el : 2, priority: 2});// state of Queue// [2, 1]// ^priorityQueue.add({ el : 3, priority: 3});// state of Queue// [3, 2, 1]// ^priorityQueue.add({ el : 4, priority: 3});// state of Queue// [3, 4, 2, 1]// ^priorityQueue.add({ el : 5, priority: 2});// state of Queue// [3, 4, 2, 5, 1]// ^
Visually, the preceding steps would generate a queue that looks like the following:

From the preceding figure, we can note how when we add an element with ...
Read now
Unlock full access