Assignment 2: Abstract Data Type
Groups: Maximum 4 students
Deadline: 30-11-2024
Objective
This assignment will help students understand how abstract data types are implemented in
C++, how to design classes, and how to manage memory efficiently when implementing data
structures.
1. Define the Interface for Stack
You are required to define the Stack ADT interface. The interface defines the essential
operations that any stack implementation must provide.
2. Implement the Stack
Once you have defined the interface, implement the stack using either a list or a linked list as
the underlying data structure.
3. Demonstrate the Stack Operations
Create a test program that demonstrates the use of the stack. This will include:
Pushing items onto the stack.
Popping items from the stack.
Checking the size and whether the stack is empty.
Using the peek operation.
4. Questions to Answer in the Assignment:
1. What is the purpose of the Stack ADT?
2. What would happen if we used a queue instead of a stack in this scenario?
3. How does the time complexity of each operation in your implementation compare?
4. Analyze the time complexity for the operations (push, pop, peek, size, is_empty).
5. Submission Requirements:
1. Code: Provide your implementation of the Stack ADT and the test program as a C++
file.
2. Documentation: Include comments explaining each method and the overall design of
the stack.
3. Test Results: Run your test program and ensure all operations work as expected.