A text editor must support an undo feature: every time the user presses undo, the MOST RECENT editing action that has not yet been undone must be reversed first. Which data structure is the most appropriate for storing the editing actions, and why?
A stack, because the last action pushed must be the first one undone, which is exactly last in, first out order
A queue, because actions must be undone in the order in which they were performed, first in, first out
A sorted array, because the actions must be kept ordered by their timestamps for quick searching
A binary search tree, because it can locate any past action in logarithmic time
The verified answer and full solution are one login away
Every answer here is machine verified, with a step-by-step solution that teaches the method. Your login also unlocks a 7-question mock preview in the real exam interface.
Log in to see the answerMore data structures questions