wiz-icon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

A circularly linked list is used to represent a Queue. A single variable p is used to access the Queue. To which node should p point such that both the operations enQueue and deQueue can be performed in constant time?


A
rear node
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
not possible with a single pointer
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
C
node next to front
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
fornt node
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is B not possible with a single pointer


To add a new node:


new next = Rear next;
Rear next = new;
Rear = new;


It will take constant time.

Similarly delete node from Front node will be:

Front = Rear next;
Rear next = Front next;
free (Front);

It will also take constant time.

flag
Suggest Corrections
thumbs-up
5
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Similar to Different
QUANTITATIVE APTITUDE
Watch in App
Join BYJU'S Learning Program
CrossIcon