↶ Text Editor Undo Feature - Stack using Linked List

Visualize how undo works using a stack implemented with nodes!

🎯 Problem: Undo Feature in Text Editor

Hi! I'm Teju 👋 We're building the undo system for a text editor using a stack.

Each typing action or change is saved as an "action ID". Pressing Ctrl+Z pops the latest action to undo it.

Operations:
PUSH x → Save new action x
POP → Undo (remove latest action)
PEEK → See latest action (without undoing)
ISEMPTY → Check if there are actions to undo

On empty stack: POP and PEEK should print "Stack Empty"

⚙️ Stack using Linked List

We use a singly linked list where new actions are added to the head (top of stack).

Undo (POP) simply removes the head node.

  • PUSH x: Create new node with value x → make it new head
  • POP: Remove head, return its value (or "Stack Empty")
  • PEEK: Return head value (or "Stack Empty")
  • ISEMPTY: Check if head is null

🎮 Interactive Demo

📜 Operation Log

Enter commands and click Run Simulation...

📤 Output (as in problem)

Program output will appear here...

↶ Undo Stack (Linked List)

Empty Stack — Nothing to Undo