ProgrammingModerate
A queue made from a singly linked list with a head and a tail pointer enqueues 1, 2 and 3, then dequeues once. What is the front value now?
- A. 1
- B. 3
- C. 0
- D. 2
Correct answer: D. 2
The dequeue removes 1 from the front, so 2 becomes the front value.
More C Programming questions
- A binary search tree is built by inserting 5, 3, 8, 1 in that order. How many nodes are in the left subtree of the root?
- Keys 2, 7 and 12 are inserted into a table of size 5 with h(k) = k % 5 using linear probing. In which slot does 12 end up?
- A chained hash table is searched for a key that is absent. The chain at its bucket has 4 nodes. How many key comparisons are made?
- A heap of 15 nodes stored as an array (complete binary tree) has what height, counting levels from 1?
- A singly linked list is searched for a value with a loop that stops when the value is found. For n nodes, what is the worst-case number of…
- A list with a sentinel head node is used to simplify insertion. What does the sentinel remove the need for?