Explore topic-wise MCQs in Data Structure Questions and Answers.

This section includes 3 Mcqs, each offering curated multiple-choice questions to sharpen your Data Structure Questions and Answers knowledge and support exam preparation. Choose a topic below to get started.

1.

Given an array of size n, let’s assume an element is ‘touched’ if and only if some operation is performed on it(for example, for performing a pop operation the top element is ‘touched’). Now you need to perform Dequeue operation. Each element in the array is touched atleast?

A. Once
B. Twice
C. Thrice
D. Four times
Answer» E.
2.

A double-ended queue supports operations like adding and removing items from both the sides of the queue. They support four operations like addFront(adding item to top of the queue), addRear(adding item to the bottom of the queue), removeFront(removing item from the top of the queue) and removeRear(removing item from the bottom of the queue). You are given only stacks to implement this data structure. You can implement only push and pop operations. What’s the time complexity of performing addFront and addRear? (Assume ‘m’ to be the size of the stack and ‘n’ to be the number of elements)

A. O(m) and O(n)
B. O(1) and O(n)
C. O(n) and O(1)
D. O(n) and O(m)
Answer» C. O(n) and O(1)
3.

You are asked to perform a queue operation using a stack. Assume the size of the stack is some value ‘n’ and there are ‘m’ number of variables in this stack. The time complexity of performing deQueue operation is (Using only stack operations like push and pop)(Tightly bound).

A. O(m)
B. O(n)
C. O(m*n)
D. Data is insufficient
Answer» B. O(n)