Queues and stacks are two fundamental data structures for computer science.
Implement a simple web crawler, that walks a website just like Google. You can try it out on https://docs.python.org/3/ and make it work like this:
Implement a priority queue using a simple array. We need to create a PriorityQueue classthat has the following methods:
put(item, priority)- inserts a new item in the queue
pop()- gets the item from the queue with the highest priority
Extra: Create another class that will return the minimum priority item from the queue instead. Hint: you can inherit from the PriorityClass.
const queue = new PriorityQueue(); queue.put("hello", 2); queue.put("world", 3); queue.put("test", 1); console.log(queue.pop()) // "world" since it has the maximum priority of 3