Skip to main contentSkip to solution

Choose the correct examples from the following where data structure 'Deque' may be applied:

A. To check whether a given string is palindrome or not

B. Evaluation of Postfix Expressions

C. Conversion of Postfix to Infix

D. Providing the Do and Undo option in text editors

Solution

✅ Correct Option: 2

A deque (double-ended queue) allows insertion and deletion at both the front and the rear.

A: For a palindrome check, load the characters into a deque, then repeatedly remove one from the front and one from the rear and compare them. This needs access to both ends.

D: Undo/redo history in a text editor is a standard deque use. New actions are added at one end, undo removes from that end, and the oldest actions are dropped from the other end when the history limit is reached.


B and C: Evaluating a postfix expression and converting postfix to infix both use a stack, since operands are pushed and popped at one end only (LIFO). A deque is not needed.

Keyboard Shortcuts

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