Correct option is B
The
Stack data structure is typically used for
UNDO and
REDO operations because of its
Last In, First Out (LIFO) property. This property allows actions to be stored and retrieved in reverse order, which is crucial for undoing and redoing tasks efficiently.
Important Key Points:
1.
UNDO Operation:
· UNDO works by popping the most recent action from the stack and reversing it.
· All performed actions are pushed onto the stack as they occur.
2.
REDO Operation:
· REDO uses a secondary stack where undone actions are pushed during the UNDO process.
· When REDO is invoked, the top action of this stack is reapplied.
Knowledge Booster:
·
Queue: Operates on a
First In, First Out (FIFO) principle, making it unsuitable for reversing or reapplying the most recent action.
·
Linked List: Can store actions but lacks the LIFO behavior required for UNDO/REDO operations.
·
Heap: A priority-based structure, unrelated to sequential action management.
·
Hash Table: Used for key-value lookups, not for sequential action processing.