# Data Structures Class 12 Computer Science Exam Questions

Please refer to Computer Science For Data Structures Class 12 Computer Science Exam Questions provided below. These questions and answers for Class 12 Computer Science have been designed based on the past trend of questions and important topics in your class 12 Computer Science books. You should go through all Class 12 Computer Science Important Questions provided by our teachers which will help you to get more marks in upcoming exams.

## Class 12 Computer Science Exam Questions Data Structures

Very Short Answer Type Questions :

Question: LIFO data structure is?

Question: Name one non-linear data structure.

Question: Can we have nested list?

Question: Name the operation for deletion from a stack.

Question: FIFO data structure is?

Question: Indexing in list starts from ?

Question: Name the operation for insertion in a stack.

Question. What are the different LIST operations ?
• Insert
• Delete
• Traverse
• Sorting
• Merging

Question. Define PUSH and POP operations in STACKS?
Answer: PUSH – To insert an element on top of the STACK.
POP – To delete an element from top of the STACK.

Question. Define the term OVERFLOW in STACKS?
Answer: OVERFLOW is an ERROR condition, when a STACK, implemented as list/array of fixed size, is full and no new element can be inserted.

Question. Which of the following is an Application of STACK?
a) Finding Factorial
b) Reversing a STRING
c) Infix to Postfix conversion
d) All of the above

Question. Convert the following Infix expression into a postfix expression?
(A-B) * (C/D) + E
Answer: POSTFIX Expression – AB – CD /*E

Question. What will be the output of the following Python code snippet?
L = [10, 20, 30, 40, 50]
Print(L[2:5])

Question. What is the purpose of list.clear() method?

Question. What is Data Structure?
Answer: Data Structure is a way of organizing and storing data in such a manner so that it can be accessed and work over it can be done efficiently and less resources are required.

Question. Define the term Linear List?
Answer: Linear Lists or Arrays refer to a named list of a finite number nof similar data type elements.

Question. A STACK is a linear structure implemented in ………… manner?
a) LIFO
b) FIFO
c) FILO
d) None of the above
Answer: LIFO (Last in First Out)

Question: What do you mean by Data Structure?
Answer: Data Structure means organization of data. A data structure has well defined operations or behavior.

Question: Name the function to find length of a list.

Question: Name one linear data structure.

Question: Name some operations commonly performed on data structures?
Answer: Traversal, Insertion, Deletion, Searching, Sorting, Merging etc.

Question: Write some applications of queue.
Answer: Sharing of resources, CPU uses queue, Airport authorities uses queue for runways and many computer algorithms uses queue.

Question: Describe similarities between stack and queue.
Answer: i)Both are special cases of linear list
ii) Both can be implemented as list.

Question: What is a list?
Answer: A list is a mutable sequence of data elements indexed by their position. A list is represented using [ ] . e.g L=[10,20,30]

Question: Name the methods used for inserting and deleting elements from a list.
Answer: Various methods for inserting elements in a list are – insert(), append(), extend() and methods used for deleting items from a list are – pop() , remove(), clear()

Question: Define Stack and Queue
Answer: Stack – A stack is a linear list also known as LIFO list with the special property that items can be added or removed from only one end called the top.
Queue – A queue is a linear list also known as FIFO list with the special property that items can be added added at one end and removed from the other.

Question: Describe differences between stack and queue.
Answer: i) A Stack is LIFO and Queue is FIFO
ii) Queue can be circular whereas Stack cannot.

Question: Write some applications of stack.
Answer: Reversing a string, compilers uses stack to store previous state of program, undo mechanism in text editors and backtracking.

Question: How is Data Structure different from Data Type?
Answer: Data Structure provides information regarding organization of data whereas Data Type provides information regarding the domain of values and operations that can be perform on data.

Question: What is traversing? Write python code to traverse a list.
Answer: Traversing means accessing or visiting or processing each element of any data structure.
L=[10,20,30,40,50]
for x in L :
print(x)

Application based Short Answer Type Questions :

Question: Predict the output:
(a) b=[[9,6],[4,5],[7,7]]
(b) b=[[9,6],[4,5],[7,7]]
X=b[:2]
X.append(10)
print(X)
Answer: [[9, 6], [4, 5], 10]
X=b[:2]
X.append(10)
print(X)
Answer: [[9, 6], [4, 5, 10]]

Question: Predict the output with respect to the list L=[40,20,30,10,50]

Question: Find the output:3.Predict the output:

Question: Consider STACK=[‘a’,’b’,’c’,’d’]. Write the STACK content after each operations:

Question: Write a python program to perform insert in a queue containing books details(bno,bname).
def Enqueue(q,book):
queue.append(q)
bno=int(input(“Enter book No:”)
bn=input(“Enter book Name:”)
books=[bno,bn]
Enqueue(queue,books)

Question: Write a python program to perform deletion from a queue containing books details(bno,bname).
front=None
def Enqueue(q,book):
if(isEmpty(queue)):
print(“UNDERFLOW”)
else:
print(“Book is “, q.pop(0))

Question: If L=[“Python”, “is”, “a”, [“modern”, “programming”], “language”, “that”, “we”, “use”] , then find the output:

Question: Given a bounded stack of capacity 4 which is initially empty, write the stack content after each steps:

Question: Evaluate the following Postfix expression: 4,10,5,+,*,15,3,/,-

Question: What is the difference between pop() and pop(0)?
Answer: pop() will delete the last element of a list whereas pop(0) will delete element at index zero of a list.

Question: Write a program to implement a stack for the students(studentno, name). Just implement Push.
Answer: Program for push operation in a stack
stk=[]
top=-1
def PUSH(stk,student):
stk.append(student)
top=len(stk)-1
sno=int(input(“Enter student No:”)
sn=input(“Enter student Name:”)
data=[sno,sn]
PUSH(stk,data)

Question: Write a program to implement a stack for the students(studentno, name). Just implement Pop and display.
Answer: Program for push operation in a stack
stk=[]
top=-1
def POP():
if(top==-1):
print(“NO STUDENT DATA”)
else:
print(“Student details are:”, stk.pop())
top=len(stk)-1
def display():
if(top==-1):
print(“NO STUDENT DATA”)
else:
t=len(stk)-1
print(stk[t])
for i in range(t-1,-1,-1):
print(stk[i])
display()
POP()