Skip to main contentSkip to solution

The elements to be inserted in the Deque are 10, 20, 30, 40, 50, 60, starting from 10.

What will be the sequence of elements after the following operations are performed on a Deque:

INSERTFRONT(), INSERTREAR(), INSERTFRONT(), DELETEREAR(), DELETEFRONT(), INSERTFRONT(), INSERTREAR(), INSERTFRONT()

A. 10

B. 40

C. 50

D. 60

Solution

✅ Correct Option: 1

Each insert takes the next unused element (10, 20, 30, 40, 50, 60), and the deque is written front to rear.

OperationElementDeque after operation
INSERTFRONT1010
INSERTREAR2010, 20
INSERTFRONT3030, 10, 20
DELETEREARremoves 2030, 10
DELETEFRONTremoves 3010
INSERTFRONT4040, 10
INSERTREAR5040, 10, 50
INSERTFRONT6060, 40, 10, 50

The final sequence 60, 40, 10, 50 is D, B, A, C.

Deleted elements (20 and 30) still use up their place in the insertion order, so the next insert gets 40, not 20.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question