You've joined the internal tools team at a productivity software company. Two internal teams are requesting features for their systems: one team needs an Undo/Redo manager for a collaborative editor, and the other needs a Help Desk ticketing system to manage customer requests in the order they’re received.
Instead of relying on built-in lists or Python's deque, you're tasked with building two custom data structures, a Stack and a Queue, using nodes and pointers. Your program should run in the terminal and allow users to:
- Perform, undo, and redo actions using a custom stack
- Add customers, serve them in order, and monitor a help desk queue
- View the current state of each system interactively
This assignment builds your understanding of how stacks and queues behave under the hood, and how pointer-based logic differs from list-based operations. These skills are foundational for interview preparation and for building tools that require predictable control over the order in which data is accessed and processed.
node.py– Contains the sharedNodeclass for both data structuresundo_redo.py– Contains theStackclass and Undo/Redo CLI interfacehelp_desk_queue.py– Contains theQueueclass and Help Desk CLI interface
Represents a single element in a linked structure.
Constructor
Node(value)Attributes
value(Any): The value stored in the node.next(NodeorNone): Pointer to the next node in the structure.
Implements a LIFO stack using linked nodes.
Constructor
Stack()Attributes
top(NodeorNone): Points to the top of the stack.
Methods
push(value): Adds a value to the top of the stack.pop(): Removes and returns the top value.peek(): Returns the top value without removing it.print_stack(): Prints the stack from top to bottom.
Implements a FIFO queue using linked nodes.
Constructor
Queue()Attributes
front(NodeorNone): First item in the queue.rear(NodeorNone): Last item in the queue.
Methods
enqueue(value): Adds a value to the end of the queue.dequeue(): Removes and returns the front value.peek(): Returns the front value without removing it.print_queue(): Prints the queue from front to rear.