Lecture 13 – Queues COMPSCI 107 Computer Science

Lecture 13 – Queues COMPSCI 107 Computer Science
1 / 1
Lecture 13 – Queues COMPSCI 107 Computer Science - slide 1 of 15 Lecture 13 – Queues COMPSCI 107 Computer Science - slide 2 of 15 Lecture 13 – Queues COMPSCI 107 Computer Science - slide 3 of 15 Lecture 13 – Queues COMPSCI 107 Computer Science - slide 4 of 15 Lecture 13 – Queues COMPSCI 107 Computer Science - slide 5 of 15 Lecture 13 – Queues COMPSCI 107 Computer Science - slide 6 of 15 Lecture 13 – Queues COMPSCI 107 Computer Science - slide 7 of 15 Lecture 13 – Queues COMPSCI 107 Computer Science - slide 8 of 15 Lecture 13 – Queues COMPSCI 107 Computer Science - slide 9 of 15 Lecture 13 – Queues COMPSCI 107 Computer Science - slide 10 of 15 Lecture 13 – Queues COMPSCI 107 Computer Science - slide 11 of 15 Lecture 13 – Queues COMPSCI 107 Computer Science - slide 12 of 15 Lecture 13 – Queues COMPSCI 107 Computer Science - slide 13 of 15 Lecture 13 – Queues COMPSCI 107 Computer Science - slide 14 of 15 Lecture 13 – Queues COMPSCI 107 Computer Science - slide 15 of 15
Lecture 13 Queues COMPSCI 107 Computer Science Fundamentals Ordered collection of data Items are added to the back of the queue Items are removed from the front of the queue Remove data in the same order as the data added First in, first

Related Topics

Download this presentation From Below

"Lecture 13 – Queues COMPSCI 107 Computer Science" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

Presentation Transcript

01
Lecture 13 – Queues COMPSCI 107 Computer Science Fundamentals<br>
02
Ordered collection of data
Items are added to the back of the queue
Items are removed from the front of the queue

Remove data in the same order as the data added
First in, first out (FIFO)

Operations
Enqueue
Dequeue
Peek
Is_empty
Size ADT - Queue 2 COMPSCI 107 - Computer Science Fundamentals<br>
03
Implementation using Python list

What is the big-O of enqueue()?

What is the big-O of dequeue()? Queue Implementation 3 COMPSCI 107 - Computer Science Fundamentals class QueueV1:
def __init__(self):
self.items = []

def is_empty(self):
return self.items == []

def enqueue(self, item):
self.items.insert(0,item)

def dequeue(self):
return self.items.pop()

def size(self):
return len(self.items)<br>