0% found this document useful (0 votes)
14 views2 pages

Stacks

computer science

Uploaded by

Ishit Adhikari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Stacks

computer science

Uploaded by

Ishit Adhikari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

TAGORE INTERNATIONAL SCHOOL

VASANT VIHAR
Class: XII
PRACTICAL FILE ASSIGNMENT NO 10

Stacks

1. A list contains the following record of books:-

[“truth”, “vindhyas”, “daffodils”, “devil”]

Write the following user defined functions to perform the given operations on the
stack named ‘books’:-

a) Push(stack,title) : for adding the elements in the stack where stack is an empty list

title is the element passed for adding it in the stack

b) Pop(stack) : Remove the element from the stack. Check the emptiness of the stack

before popping each element.

2. Write the following user defined function to perform the given operations on the stack
named ‘quotes’:-
a. push(): To push a string accepted from the user into the stack.
b. pop(): To pop the words from the stack and display the words in reverse order

For example:-

If string is “Hello World”

The output should be “World Hello”

3. Define the function pop() for the previous question to pop string from the stack and
display the string in reverse order.

For example:-

If string is “Hello World”

The output should be “dlorW olleH”

4. A list following record of customer:-

[“Customer_name”, “Room Type”]


Write the following user defined functions to perform given operations on the stack
named ‘Hotel’:-
i) Push_Cust(): To Push customers’ names of those customers who are staying in
‘Deluxe’ Room Type.
ii) Pop_Cust(): To Pop the names of customers from the stack and display them. Also,
display “Underflow” when there are no customers in the stack.

For example:
if lists with customer details are as follows:
[“Siddharth”, “Delux”]
[“Rahul”, “Standard”]
[“Jerry”, “Delux”]
The stack should contain:-
Jerry
Siddharth
The Output should be:-
Jerry
Siddharth
Underflow

5. Write a function in Python, Push(Vehicle) where, Vehicle is a dictionary containing


details of vehicles: {Car_Name: Maker}.

The function should push the name of the car manufactured by ‘TATA’(in all cases
possible) to the stack.

For example:-

If the dictionary contains the following data:

Vehicle={“Santro”: “Hyundai”, “Nexon”: “TATA”, “Safari”: “Tata”}

The stack should contain:-

Safari

Nexon

You might also like