Transcript for:
Understanding Queues in Data Structures

today i'm going to teach you about cues cues are  an elementary data structure that represent a   dynamic set of data we insert and delete elements  into a queue but the delete operation is done in   a predefined manner for cues this is called fifo  or first in first out we call the insert method   in queue and the delete method dq dq takes  no arguments let's look at an example here's what we use to represent our queue i've  marked the front and the back you'll see later in   our python example that we'll implement this with  collections.dq which is a doubly linked list this   allows us to enqueue and dequeue in constant  time we'll insert elements at the back of the   queue and remove them from the front we start  with an empty cue and insert the element one it's added at the back but because  the cue is empty it's first in line let's add a few more elements two and three notice two and three are added at  the back behind the element one   we dequeue our first element removing one which was the first element added to the queue pretty simple i'll let the rest of  the example play without voiceover lastly let's look at the code which is shown  in python and linked in the description   we'll use collections.dq as our queue  and implement the inque and dq method   for enqueue we simply append the element to the  end for dq we call pop left which removes the   element at the front of the queue because  collections.dq is represented internally   as a doubly linked list this operation is  achieved in constant time as is in queue in computing cues have numerous uses operating  systems use them extensively for cpu and disk   scheduling when you swipe right on a song  in spotify you're adding it to a queue   and if you've watched my other videos you've seen  we've used cues to implement breadth first search thank you for watching i hope this video  helps you on your computer science journey   please like and subscribe