Filters
Question type

Study Flashcards

How would you use a Python list method to remove and return an item at the front of the queue?


A) peek(len(queue) -1)
B) peek(1)
C) pop(len(queue) -1)
D) pop(0)

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

What happens to processes on the ready queue in a round-robin CPU scheduling scheme?


A) they are pushed and put in the priority queue
B) they are popped and allocated memory
C) they are pushed to the end of the queue
D) they are popped and given a slice of CPU time

E) B) and C)
F) A) and D)

Correct Answer

verifed

verified

Queues are linear collections.

A) True
B) False

Correct Answer

verifed

verified

Each process on the ready queue is pushed onto a stack before being given a slice of CPU time.

A) True
B) False

Correct Answer

verifed

verified

The array implementation of a queue must access items at the logical beginning and the logical end.

A) True
B) False

Correct Answer

verifed

verified

The two fundamental operations supported by queues are pop and insert.

A) True
B) False

Correct Answer

verifed

verified

When using a circular array implementation for a queue, you maintain a count of the items in the queue to determine if it is full or empty.

A) True
B) False

Correct Answer

verifed

verified

What is the initial value of the front and rear instance variables in the linked queue?


A) -1
B) 0
C) None
D) 1

E) C) and D)
F) A) and C)

Correct Answer

verifed

verified

The peek operation on a queue returns the item at the back of the queue without removing it.

A) True
B) False

Correct Answer

verifed

verified

The structure of a queue lends itself to either an array implementation or a linked implementation.

A) True
B) False

Correct Answer

verifed

verified

What are the two fundamental operations of a queue?


A) insert, push
B) insert, pop
C) push, add
D) add, pop

E) A) and D)
F) None of the above

Correct Answer

verifed

verified

What is the precondition to using the pop method on a queue?


A) the queue must not be empty
B) the queue must be full
C) the queue must not be full
D) the queue must first be resized

E) A) and C)
F) B) and C)

Correct Answer

verifed

verified

What is the returned value and the state of the queue after the operation is executed? Current queue state: x a z b Q.peek()


A) b, x a z b
B) x, a z b
C) x, x a z b
D) b, x a z

E) A) and C)
F) All of the above

Correct Answer

verifed

verified

In the following code for the add method for a linked queue implementation, what is the missing code? def add(self, newItem) : NewNode = Node(newItem, None) If self.isEmpty() : Self.front = newNode Else: Self.rear.next = newNode < missing code > Self.size += 1


A) self.rear = newNode
B) self.rear -= 1
C) self.rear.prev = None
D) self.front = self.next

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

In the following code for the __eq__ method for the Comparable class, what is the missing code? def __eq__(self, other) : If self is other: return True If type(self) != type(other) : < missing code > Return self.priority == other.priority


A) return type(other)
B) return other
C) return False
D) return self.priority

E) All of the above
F) B) and C)

Correct Answer

verifed

verified

The list data structure in Python cannot be used to emulate a queue because there is no pop method.

A) True
B) False

Correct Answer

verifed

verified

By using a circular array implementation, you can simultaneously achieve good running times for both add and pop .

A) True
B) False

Correct Answer

verifed

verified

In the linked priority queue, what is the time and space analysis for the add method?


A) O( n2 )
B) exponential
C) logarithmic
D) O( n )

E) B) and C)
F) None of the above

Correct Answer

verifed

verified

Performing a pop operation on an empty queue throws an exception.

A) True
B) False

Correct Answer

verifed

verified

Similar to stacks, queues support a FILO protocol.

A) True
B) False

Correct Answer

verifed

verified

Showing 21 - 40 of 50

Related Exams

Show Answer