Data Structures · Question 16 · Easy

Data Structures question 16

Which data structure is the most natural choice for implementing the Undo feature of a text editor, where the most recent change must be reversed first?

  1. Stack
  2. Queue
  3. Hash table
  4. Binary search tree
Answer and explanation

Answer: A. Stack

Explanation: Undo must reverse the latest action first, which is Last-In-First-Out behaviour, so each edit is pushed on a stack and Undo pops it.

Previous: Two stacks share a single array arr[0..n-1]. Stack 1 starts at index 0 and… · Next: What is the time complexity of inserting a new node at the beginning (head) of…

Practise data structures

Try a fresh set of data structures questions with an explanation after every answer, free and without signing up: Data Structures practice. Or sit a full placement mock test.

More data structures questions

More technical & programming practice

Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge