Chapter - Stacks
Q1. Consider a stack as a list containing following data:
Stack=[100,200,300,400,500,600] with top of the stack as 600.
Display the stack after each of the following operations:
Stack.pop()
Stack.append(700)
Stack.pop()
Stack.append(800)
Stack.append(900)
Stack.pop()
Q2. Consider a stack as a list containing following data:
Stack=[“Amit”, “Babita”, “Mahesh”,”Kiran”,”Shubha”] with top of the stack as Shubha.
Display the stack after each of the following operations:
Stack.pop()
Stack.append(“Keshav”)
Stack.append(“Rakshit”)
Stack.pop()
Stack.append(“Raghav”)
Stack.pop()
Q3. Write a menu driven program to implement a stack as list containing Month names as
information. Write functions for push, pop and display.
Q4. Write a complete menu driven to implement stack as a list containing numbers. Write
functions for push, pop and display.
Q5. Write a complete menu driven program to implement a stack as a list containing Item Name,
Quantity and Price as information. Write functions for push, pop and display.
Q6. Write a complete menu driven program to implement a stack as a list containing Doctor name,
Department and Salary as information. Write functions for push, pop and display.
Q7. Write a function in python, MakePush(Package) and MakePop(Package) to add a new Package
and delete a Package from a List of Package Description, considering them to act as push and
pop operations of the Stack data structure.
Q8. Write a function pop() which returns a number which is deleted from a stack implemented as
a list containing numbers.
Q9. Write a function empty() which return -1 if the stack implemented as a list containing numbers
is empty.
Q10. Write a function in Python PUSH(Arr), where Arr is a list of numbers. From this list push all
numbers divisible by 5 into a stack implemented by using a list. Display the stack if it has at
least one element, otherwise display appropriate error message.