From the course: Python Data Structures: Stacks, Deques, and Queues

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Solution: Printer problem

Solution: Printer problem

(bright upbeat music) - [Instructor] Welcome back, I hope you had fun attempting the printer problem code challenge. And in this video we'll be having a look at the output actually given. First we see that we have given the class Queue, and this is the class that we are going to be coding under. So we see that there is initialized function over here and over here. And for this function, we don't actually have to make any changes as anything that we need to initialize our class has already been given to us. And so moving on to the next function, the enqueue function. Now if you remember from our lesson in the chapter about enqueue, we can use the append method in order to add an element to the end of the list. And in this case, it'll be any piece of data that we may need to add. Then we move on to the dequeue function. So first of all, we start off by checking if the queue is empty. To do so, we're using the isEmpty function, which we'll come onto in a second. And then we use the pop…

Contents