0% found this document useful (0 votes)
13 views

Copy of Stacks

Uploaded by

harish.m
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Copy of Stacks

Uploaded by

harish.m
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

WORKSHEET – DATA STRUCTURES - STACKS

Name: _________ Level :


XII

1. Write an interactive menu-driven program implementing Stack


using list. The list is storing numeric data.
2. Write an interactive menu-driven program to implement Stack
using list. The list contains the names of students.
3. Give the necessary declaration of a list implemented Stack
containing float type numbers. Also, write a user-defined
function to pop a number from this Stack.
4. A linear Stack called Directory contains the following
information:
-- Pin code of city
-- Name of city
Write add(Directory) and delete(Directory) methods in Python
to add and remove contacts using append() and pop()
operations in Stack.

5. Write AddCustomer(Customer) and


DeleteCustomer( Customer) methods in Python to add a new
Customer and delete a Customer from a List of
CustomerNames, considering them to act as push and pop
operations of the stack data structure.
6. Write a program to perform push and pop operations on a
Stack containing Members' details as given in the following
definition of dictionary.

Member No - Integer (Key)

Member Name - String

Age - Integer

# Write the code to insert member details in stack if their age


> 35.

# Write the code to delete a recently added member.

7. Julie has created a dictionary containing names and marks as


key value pairs of 6 students. Write a program, with separate
user defined functions to perform the following operations:

● Push the keys (name of the student) of the dictionary into a


stack, where the corresponding value (marks) is greater than
75.
● Pop and display the content of the stack. For example: If the
sample content of the dictionary is as follows:

R={"OM":76, "JAI":45, "BOB":89, "ALI":65, "ANU":90,


"TOM":82}

The output from the program should be: TOM ANU BOB OM

8. Alam has a list containing 10 integers. You need to help him


create a program with separate user defined functions to
perform the following operations based on this list.

● Traverse the content of the list and push the even numbers
into a stack.

● Pop and display the content of the stack. For Example: If the
sample Content of the list is as follows:

N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]

Sample Output of the code should be: 38 22 98 56 34 12

9. Write a python program to read a line of text and Print it in


reverse.

10. 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