![]() |
| Stack Using List |
Assignment-7: Stack using list
Task 1: Define Stack class with init()
Define a class Stack to implement stack data structure using list. Define
__init__() method to create an empty list object as instance object member of Stack.Task 2: Define is_empty() method
Define a method
is_empty() to check if the stack is empty in Stack class.Task 3: Define push() method
In Stack class, define
push() method to add data onto the stack.Task 4: Define pop() method
In Stack class, define
pop() method to remove top element from the stack.Task 5: Define peek() method
In Stack class, define
peek() method to return top element on the stack.Task 6: Define size() method
In Stack class, define
size() method to return size of the stack that is number of items present in the stack.
No comments:
Post a Comment