CS – Stack IMP Questions
-by kuzhali (Given for reference)
Objective Type Questions -Data Structure stack
Class 12 Questions
Objective type questions of Data Structure stack Class 12 Questions contain MCQs, 1-word
answer questions, Fill in the blanks or true false.
[1] A ____________ is a way to store, organize, or manage data in efficient and productive
manner.
Ans: Data Structure
[2] A stack is one of the following types of data structure?
a) Linear b) Dynamic c) Circular d) All of these
[3] Stack data structure is following ____________ principle.
Ans: LIFO
[4] In stack data can be inserted or deleted from ____________ only.
Ans: Top
[5] The insert operation in the stack is known as pop. (True/False)
[6] You can replace any element position in the stack. (True/False)
[7] The peek operation refers to accessing/inspecting the top element in the stack. (True/False)
[8] A condition raise due to the stack is full is known as ___________.
a) Underflow b) Overflow c) List is full d) Completely Filled
[9] While popping the element from the stack, a condition will be raised, this condition is known as
____________.
a) Underflow b) Overflow c) List is Empty d) Blank List
[10] Stack overflow condition is raised in ____________ operation whereas Stack underflow
condition is raised in _____________ operations.
Ans: Push, Pop
Short answer questions (2 Marks – Questions) –
Data Structure stack Class 12 Questions
So here we start the next section of Data Structure stack Class 12 Questions for 2 marks
questions. Here we go!
[1] What do you mean by data structure? Explain your answer with a suitable example.
Ans.: The systematic way of organizatiron,storing, accessing and retrieving data including well-
defined operations, behavior and properties is known as data structure.
Examples:
1. String – Contains sequence of characters
2. List – Contains sequence of different data types
[2] What do you mean by the LIFO structure? Support your answer with real-life examples.
Ans.: LIFO is one of the principle to access data from a data structure. It stands for Last In First
Out. It refers to the item which is inserted last will be access frist. So the top element will be
accessed first.
Example:
1. Books in the shelf
2. Stack of coins
3. Pile of chairs
4. Bangles on woman’s wrist
[3] Enlist a few of the fields where you feel a stack is used in real life.
Ans.: The stack is used in many fields in our routine life. Some examples are:
1. Browsers History
2. Mobile Phone Call log
3. Tubewell boring machine
4. Undo and redo commands in software
[4] What are the basic operations that can be performed on the stack?
Ans.: There are two basic operations can be performed on the stack:
1. Push – Inserting an element
2. Pop – Deleting an element
[5] What are the underflow and overflow conditions?
Ans.: Underflow is the condition which occurs when stack is empty while trying to delete elements.
Overflow is the condition which occurs while inerting an element when memory is exhausted.
[6] Write steps on how you implement stack?
Ans.: The steps are:
1. Create a stack
2. Push an element
3. Pop an element
4. Traverse/Display an element
[7] Write a python function named is_underflow() to check a stack is an underflow.
def is_underflow(stk):
if stk==[]:
return True
else:
return False
[8] Write a function to push an element into the stack.
def push(stk,e):
[Link](e)
top = len(stk)-1
[9] Write a python function to delete an element from the stack.
def pop_stack(stk):
if stk==[]:
return "UnderFlow"
else:
e = [Link]()
if len(stk)==0:
top = None
else:
top = len(stk)-1
return e
[10] Write a function to display the stack elements.
def display(stk):
if stk==[]:
print("Stack is Empty")
else:
top = len(stk)-1
print(stk[top],"-Top")
for i in range(top-1,-1,-1):
print(stk[i])
[11] Write a function to inspect an element from the stack.
def peek(stk):
if stk==[]:
return "UnderFlow"
else:
top = len(stk)-1
return stk[top]
[12] Write functions AddPlayer(player) and DeletePlayer(player) in python to add and
remove a player by considering them as push and pop operations in a stack.
def AddPlayer(player):
pn=input("enter player name:")
[Link](pn)
def DeletePlayer(player):
if player==[]:
print("No player found")
else:
return [Link]()
[13] Vedika has created a dictionary containing names and marks as key-value pairs of 5
students. Write a program, with separate user-defined functions to perform the following
operations:
1. Push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 70.
2. Pop and display the content of the stack.
The dictionary should be as follows:
d={“Ramesh”:58, “Umesh”:78, “Vishal”:90, “Khushi”:60, “Ishika”:95}
Then the output will be: Umesh Vishal Ishika
def push(stk,item):
[Link](item)
def Pop(stk):
if stk==[]:
return None
else:
return [Link]()
stk=[]
d={"Ramesh":58, "Umesh":78, "Vishal":90, "Khushi":60, "Ishika":95}
for i in d:
if d[i]>70:
push(stk,i)
while True:
if stk!=[]:
print(Pop(stk),end=" ")
else:
break