Stack Lab 6
1. Undo/Redo Feature in a Text Editor
Scenario: A text editor needs an undo/redo feature using stacks.
Task:
Implement two stacks (undoStack and redoStack) to store text operations.
Perform undo (pop from undoStack and push to redoStack) and redo (pop from
redoStack and push back to undoStack) actions.
2. Browser History Navigation
Scenario: A web browser needs to store visited pages for back and forward navigation.
Task:
Implement two stacks (backStack and forwardStack).
Allow users to visit a new page, go back, and move forward.
3. Checking Balanced Parentheses in Expressions
Scenario: A compiler needs to validate expressions containing brackets ((), {}, []).
Task:
Implement a stack to push and pop brackets.
Check if an expression is balanced (e.g., ({[]}) is valid, but ({[}) is not).
4. Reverse a String Using Stack
Scenario: A system needs to reverse a string using a stack.
Task:
Implement a stack to push each character of a string.
Pop characters from the stack to form the reversed string.
5. Stack-Based Expression Evaluation (Postfix Calculator)
Scenario: A calculator processes postfix expressions like 23*5+.
Task:
Use a stack to evaluate a postfix expression by pushing numbers and applying operations
when encountering +, -, *, /.
6. Managing Train Coaches Using Stack
Scenario: A railway station wants to manage train coaches in a last-in, first-out order.
Task:
Implement a stack where newly arrived coaches are pushed and dispatched coaches
are popped.
7. Implementing a Stack-Based Playlist
Scenario: A music player allows users to add and remove songs in a last-in, first-out order.
Task:
Implement a stack to add, remove, and display the last played song.
8. Tower of Hanoi Using Stacks
Scenario: Solve the Tower of Hanoi problem using three stacks.
Task:
Implement three stacks (Source, Auxiliary, Destination).
Move disks between stacks following Hanoi rules.
9. Book Return System in a Library
Scenario: A library manages recently returned books using a stack.
Task:
Implement a stack to push returned books.
The librarian processes books in last-returned order (pop operation).
10. Stack-Based Undo System in a Drawing Application
Scenario: A drawing application allows users to undo their last actions.
Task:
Implement a stack where each draw action is pushed.
Allow users to undo (pop) the last action and redo (re-push).