Please fill out this quiz, and press the "Submit" button at the end. Don't collaborate with anyone on quiz exercise solutions.
Please answer all questions.
SID: [No spaces and no dashes.]
Login ID :
1. You may recall from CS61B that a queue is a first-in-first-out data structure, with two operations: enqueue(x) appends the element x to the tail of the queue; dequeue() returns the element at the head of the queue, removing it from the queue. (The difference between a queue and a stack is that a queue is a first-in-first-out data structure, while a stack is a first-in-last-out data structure.)
Suppose we have an efficient implementation of a queue (such as a doubly-linked list with a head and tail pointer). Let N denote the number of elements currently in the queue.
(a) What is running time of the enqueue() operation, using big-O notation? No explanation needed.
(b) What is running time of the dequeue() operation, using big-O notation? No explanation needed.
Suppose we have an efficient implementation of a priority queue (such as one that uses a binary heap). Let N denote the number of elements currently in the priority queue.
(a) What is running time of the insert() operation, using big-O notation? Explain briefly.
(b) What is running time of the deletemin() operation, using big-O notation? Explain briefly.