UGC-NET Dec 2013 · Linked Lists

MCQ · 2 marks · Problem PROG-DSTR-0051

If the queue is implemented with a linked list, keeping track of a front pointer, which of these pointers will change during an insertion into an non-empty queue?
  1. A
    Neither of the pointer change
  2. B
    Only front pointer changes
  3. C
    Only rear pointer changes
  4. D
    Both of the pointer changes

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solutionInsertion into a linked-list queue adds the new node after the current last node:\[\text{rear}\to\text{next}=\text{new};\qquad \text{rear}=\text{new}.\]In a non-empty queue the front node is unchanged, so only the rear pointer changes. (Both change only when inserting into an empty queue.)Answer: C

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com