0% found this document useful (0 votes)
326 views1 page

Chapter-Stack Assignment

The document discusses stacks and operations on stacks like push and pop. It provides examples of stacks containing different data like numbers, names, items etc. It then asks questions about implementing stacks as lists and writing functions for common stack operations like push, pop and display. Functions are to be written to add and remove elements from stacks containing packages, numbers, doctors details etc. Questions also involve pushing selected elements from a list into a stack.

Uploaded by

Bhaumik Solanki
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
326 views1 page

Chapter-Stack Assignment

The document discusses stacks and operations on stacks like push and pop. It provides examples of stacks containing different data like numbers, names, items etc. It then asks questions about implementing stacks as lists and writing functions for common stack operations like push, pop and display. Functions are to be written to add and remove elements from stacks containing packages, numbers, doctors details etc. Questions also involve pushing selected elements from a list into a stack.

Uploaded by

Bhaumik Solanki
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 1

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.

You might also like