The Gateway to Computer Science Excellence
+2 votes

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. Neither of the pointer change
  2. Only front pointer changes
  3. Only rear pointer changes
  4. Both of the pointer changes
in Programming by Veteran (105k points)
recategorized by | 1k views

1 Answer

+2 votes

In linked list implementation of a queue, the last inserted node is always pointed by 'rear' and the first node is always pointed by 'front'.


In above example, the last inserted node is 50 and it is pointed by 'rear' and the first inserted node is 10 and it is pointed by 'front'. The order of elements inserted is 10, 15, 22 and 50.

Hence,Option(C)only rear pointer changes.


by Boss (41.2k points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,258 answers
104,736 users