Data Structures MCQ Quiz in मल्याळम - Objective Question with Answer for Data Structures - സൗജന്യ PDF ഡൗൺലോഡ് ചെയ്യുക
Last updated on Mar 9, 2025
Latest Data Structures MCQ Objective Questions
Top Data Structures MCQ Objective Questions
Data Structures Question 1:
In python, Which of the following method is used find weather the queue is empty or not?
Answer (Detailed Solution Below)
Data Structures Question 1 Detailed Solution
The correct answer is option 3.
Concept:
Queues:
- The queue is an abstract data structure, somewhat similar to Stacks.
- Unlike stacks, a queue is open at both ends. One end is always used to insert data (en queue) and the other is used to remove data (de queue). Queue follows the First-In-First-Out methodology, i.e., the data item stored first will be accessed first.
- Queue follows the principle of First In First Out (FIFO) and Last In Last Out (LILO)
maxsize:
The maximum number of items in the queue.
put(item):
Add something to the queue. Wait until a free spot becomes available if the queue is filled before adding the item.
qsize():
Return the number of items in the queue.
full():
If there are maxsize items in the queue, return True.
get():
A queue item can be removed and returned. Wait until an item is available if the queue is empty.
empty():
Return True if the queue is empty, False otherwise. Here queue is not empty because the still elements are there in the queue. Example:
Explanation:
from queue import Queue
q=Queue(maxsize=10)
q.put('A')
q.put('AA')
q.put('AAA')
print(q.qsize())
print(q.full())
print(q.get())
print(q.empty())
Hence the correct answer is empty().
Data Structures Question 2:
What will be the output for the given python code?
import collections
dq = collections.deque([4, 5, 6,7,8])
dq.reverse()
print(list(dq))
Answer (Detailed Solution Below)
Data Structures Question 2 Detailed Solution
The correct answer is option 1.
Concept:
A deque is a two-ended queue in which elements can be inserted and deleted from either the left or right end. The collections module in Python has a deque implementation.
reverse():
Reverse the order of the deque.
Explanation:
The given data,
import collections
dq = collections.deque([4, 5, 6,7,8])
Here the deque has 4, 5, 6, 7, 8.
dq.reverse()
The reverse function is the order of the deque. The deque has [8, 7, 6, 5, 4]
print(list(dq))
The deque prints [8, 7, 6, 5, 4].
Hence the correct answer is [8, 7, 6, 5, 4].
Data Structures Question 3:
Any arithmetic expression cannot be represented in which of the following notations?
Answer (Detailed Solution Below)
Data Structures Question 3 Detailed Solution
The correct option is Midfix
CONCEPT:
There are mainly three notations used for writing expression:
Infix notation: When the operator is written in between the operands it is known as infix notation. Example 2+5
Prefix notation: When the operator is written before the operands it is known as Prefix notation. Example +25
Postfix notation: When the operator is written after the operands it is known as Postfix notation. Example 25+
But there is no notation like Midfix to represent an expression.
Data Structures Question 4:
Which of the following statements are correct for Queue?
A. Queue is an ordered linear data structure
B. Deque can support both stack and queue operations
C. Queue is a non-linear data structure
D. Queue works on FILO principle
E. Deque is a version of Queue which does not allow insertion and deletion at both ends
Choose the correct answer from the options given below:
Answer (Detailed Solution Below)
Data Structures Question 4 Detailed Solution
The correct answer is A and B only
Key Points
- A. Queue is an ordered linear data structure (CORRECT)
- Queues follow a specific order, adhering to the FIFO (First-In-First-Out) principle.
- Elements are arranged linearly, one after the other.
- B. Deque can support both stack and queue operations (CORRECT)
- Deque (double-ended queue) allows insertion and deletion at both ends, making it flexible.
- It can mimic stack behavior by performing operations at one designated end.
- C. Queue is a non-linear data structure (INCORRECT)
- As mentioned earlier, queues maintain a linear order of elements.
- D. Queue works on FILO principle (INCORRECT)
- Queues operate on FIFO, meaning the first element added is the first one removed.
- FILO (First-In-Last-Out) describes stacks, where the last element added is accessed/removed first.
- E. Deque is a version of Queue which does not allow insertion and deletion at both ends (INCORRECT)
- The defining characteristic of a deque is its ability to perform operations at both ends, unlike a standard queue (insertion at rear, deletion from front).
Therefore, the correct answer is 2) A and B only.
Data Structures Question 5:
What is the output for the given python code?
a = []
a.append('1')
a.append('2')
a.pop()
a.append('3')
a.append('4')
print(a)
Answer (Detailed Solution Below)
Data Structures Question 5 Detailed Solution
The correct answer is option 3.
Concept:
Stack:
A Stack is a data structure that is linear. It uses the Last In, First Out (LIFO) storage mechanism. A new element is always added to the top of a stack when it is added, and the top element is always removed first from a stack.
Explanation:
The given code is,
a = []
a.append('1')
a.append('2')
a.pop()
a.append('3')
a.append('4')
print(a)
It follows the below figure manner.
Hence the correct answer is ['1', '3', '4 '].
Data Structures Question 6:
Assertion A: Dequeue can support both stack and queue.
Reason R: Dequeue supports insertion and deletion at both ends.
In the light of the above statements, choose the most appropriate answer from the options given below:
Answer (Detailed Solution Below)
Data Structures Question 6 Detailed Solution
In stack, we use to insert in the front, and in the queue, we used to insert from the back. So, both work we can do on de queue, That's why it's called as Double Ended queue.
dequeue allows you to efficiently add or remove the item from Either end of the list.
So, the Assertion statement is correct.
Now, the reason is also true and correctly explains the assertion. In the de queue, we can insert and delete from both the ends that's why it can support both stack and queue.
de queue is implemented as a double-linked list in the system and we can insert and delete from both ends.
So, option 3 turns out to be the correct answer as Reason correctly explains the Assertion.
Data Structures Question 7:
Which of the following statements is False?
Statement 1: A single deque can support both stack and queue operations.
Statement 2: A single stack can support both deque and queue operations.
Statement 3: A single queue can support both stack and queue operations.
Answer (Detailed Solution Below)
Data Structures Question 7 Detailed Solution
The correct answer is option 3.
Concept:
Statement 1: A single deque can support both stack and queue operations.
True, The word deque, usually pronounced deck, is short for double-ended queue. A deque is a list that supports insertion and removal at both ends. Thus, a deque can be used as a queue or as a stack.
- A deque elements insertion and deletion are done from only one end so it follows the stack property(First in Last out).
- A deque elements insertions are done from only one end and deletion is done from another end. so it follows the queue property(Last in first out).
Statement 2: A single stack can support both deque and queue operations.
False, A stack can not supports the deque and queue operations because it has the restriction that insertion and deletion are done from only one end.
Statement 3: A single queue can support both stack and queue operations.
False, A queue can not supports the deque operations because it has the restriction that insertion on one end and deletion is done from another end.
Hence the correct answer is only statement 2 and statement 3.
Data Structures Question 8:
What will be the value printed by the following python code:
#consider stack is already implemented for you and has predefined pop and push method.
s=stack()
sum=0
s.push(15)
s.push(5)
s.pop()
s.push(7)
s.push(11)
while( len(stack) > 0 ):
sum=sum + s.pop()
print(sum)
Answer (Detailed Solution Below)
Data Structures Question 8 Detailed Solution
The correct option is 33
CONCEPT:
Stack is a data structure that follows last in first out order for insertion and deletion of items.
The insertion and deletion of items take place from one end only using the top pointer.
EXPLANATION:
In the above program, the following operations are performed on the stack "s" before executing the for loop
push(15), push(5), pop(), push(7), push(11)
Now items of the stack are popped one by one in the while loop and added to the sum variable
#iteration 1 : sum = sum + s.pop() = 0 + 11
#iteration 2 : sum = sum + s.pop() = 11 + 7
#iteration 3 : sum = sum + s.pop() = 18 + 15
after popping 3 items from the stack, the stack becomes empty and the while loop stops/ends.
The final value of sum = 33 that will be printed in the end.
Data Structures Question 9:
Which of the following is a correct syntax to assign an empty list to the identifier named stackone?
Answer (Detailed Solution Below)
Data Structures Question 9 Detailed Solution
Correct option is stackone = list()
CONCEPT:
Lists in Python can be created using list() method or by placing the values inside square brackets[], for example
a=[1,2,3]
or we can create list using list() method and then add elements using append() method
a=list()
a.append(1)
a.append(2)
a.append(3)
In the above question
Option 2 stackone != list()
/ here not-equal-to operator is used which is a comparision operator.
Option 3 stackone = list[]
/ invalid syntax list[]
Option 4 stackone = stacklist()
/ error as there is no method named stacklist()
Data Structures Question 10:
In python, to support enqueue and dequeue operations which operations are used?
Answer (Detailed Solution Below)
Data Structures Question 10 Detailed Solution
In queue , enqueue means inserting an element and dequeue means deleting an element from the queue.
Remember , delete should happen from the front and insert should happen from back ( rear ) side.
So, To implement the enqueue operation , we need to first check the queue is full or not, for that we use isfull() function , which returns a binary value - either true or false .
To implement dequeue operation we need to first check if element present in the queue or not, for that we need isempty() function , if the function returns false that means queue have at least 1 element and we can delete that.
peek() function used to return the front element of the queue , as deletion happens from the front , so, we need peek operation to find out the front element.
So, option 3 will be the correct answer .
Why option 1 and 2 got eliminated -
we need 3 operation ( isempty,isfull,peek ) combine for the operation , and the options does not satisfy that .
why option 4 got eliminated -
insertrear() function used to insert an element in the rear position , but here , in this question , we do not require that.