Friday, October 24, 2025

➡️DSA using Python: Assignment-8: Stack Extending List

Follow me

This assignment is designed for practicing Stack implementation using Python by extending the built-in list class. It helps you learn how to create a custom stack data structure with essential methods like push(), pop(), peek(), is_empty(), and size(), and how to restrict certain list methods to maintain stack behavior.

Assignment-8: Stack Extending List


🧱 Task 1: Create Stack Class

Define a class Stack to implement stack data structure by extending list class.

🧱 Task 2: Check if Stack is Empty

Define a method is_empty() to check if the stack is empty in Stack class.

🧱 Task 3: Add Element to Stack

In Stack class, define push() method to add data onto the stack.

🧱 Task 4: Remove Top Element

In Stack class, define pop() method to remove top element from the stack.

🧱 Task 5: View Top Element

In Stack class, define peek() method to return top element on the stack.

🧱 Task 6: Find Stack Size

In Stack class, define size() method to return size of the stack that is number of items present in the stack.

🧱 Task 7: Restrict Unwanted List Methods

Implement a way to restrict use of insert() method of list class from stack object.

No comments:

Post a Comment

Recursion in DSA using Python

Follow me If you want to understand with  Graphical Representation   click on it. You can find the explanatory video at the bottom of this p...