QUESTION 31 A Queue of characters currently contains a b c d .
Qualcomm technical mcq question, verified with a worked answer. Free to practise - no sign-up.
QUESTION 31
A Queue of characters currently contains a b c d. What would be the content of the queue after the below operations?
I) DeletII) Addition of w followed by x
III) DeletIV) Addition of y
Show answer & explanation
A queue operates on FIFO (First-In-First-Out) principle. Starting with [a b c d] (a at front), deletion removes 'a', then additions of w and x enqueue them at the rear, followed by deletion of 'b', and finally addition of 'y' results in [c d w x y].
Step-by-step Derivation:
Initial queue (front to rear): [a b c d]
I) Delete: Remove front element 'a' → [b c d]
II) Add w: [b c d w]
II) Add x: [b c d w x]
III) Delete: Remove front element 'b' → [c d w x]
IV) Add y: [c d w x y]
Final queue: c d w x y