In this lesson, you'll learn how we can combine several queues to create a new data structure: a priority queue. A priority queue allows the user to add items to the queue that are deemed to be high priority, and get moved ahead in the line. This added complexity is simple to achieve and is a good example of how we can build up complexity through the use of data structures.
Hi, I'm not sure if this is the right way to teach priority queues in case newcomers to data structures and algorithms are watching this. I mean the idea is more or less correct but we don't really implement priority queues like this. In fact in the real world, you'll most implement priority queues using hash tables or binary heaps. With the above method, you cannot do things like: changing priorities, fetching data according to specific priorities etc. It's not that something like you've shown can't exist but it's not how it's done in the "industry". At least I've never seen a priority queue being implemented like this and I've interviewed in as well as used quite a bit of ds and algos at work. Maybe, in addition to this, you can showcase priority queues being implemented with hashing or heaps.
Hi DIYA, thanks for sharing this. You’re right that this is not a very robust solution, this was intended to demonstrate how something more complex could be constructed of simple elements. None of the implementations in this course are precisely how I would expect them to be implemented, as this is more about instruction and theory than it is about production ready code. That being said, you are correct that it might be cool to make a lesson on how to create heaps and make a more robust solution than this one in the future. Perhaps I’ll have to make an update or a Volume 2 for this series.
As an intermediate javascript developer this has helped me become more exposed to thinking like a programmer. I would agree though that if I were a newcomer or beginner venturing out into my programming career, it would be hard to understand the "why"s here, but thank you so much for a great tutorial! As for DIYA's comment, i'm interested to see a real world example now. A second course (volume 2) would be great Kyle!
Hi, got "TypeError: createQueue is not a function" when I try to use your code in VsCode, don't see what I am missing ?
Update: It works when I do "exports.createQueue = function createQueue()" in "index.js" but would like to know how you do the trick on your side ?
No trick, probably a broken export import situation. I will look into it later when I’m on my computer and not my phone.
This is awesome stuff Kyle. Though I understand Diya concerns, I think this is a huge step in the right direction. I have been a JS pro for the last 12 years though I did not finish the CS training. You made me feel less dumb today. Let's all remember the first day our Math professor was adding letters and numbers together and tried to convince us that: x + 2 = y; Jokes aside what am advocating for is more empathy towards the beginner and intermediate. If this is not production ready, hell now I'm motivated and excited to dig deeper and find out what is. This really made the egghead subscription worth it.