DS MCQ
DS MCQ
MCQ on DS
A. One pointer
B. Two pointers
C. Three pointers
D. No pointer
2. Linked lists are not suitable for data structures for which one of the following problems?
3. The concatenation of two lists is to be performed in O(1) time. Which of the following
implementations of a list should be used?
4. In the worst case, the number of comparisons needed to search a singly linked list of length n for a
given element is
A. log2n
B. n/2
C. log2n – 1
D. n
5. Let P be a singly linked list. Let Q be the pointer to an intermediate node x in the list. What is the worst
case time complexity of the best-known algorithm to delete the node x from the list?
(A) O(n)
(B) O(log2 n)
(C) O(log n)
(D) O(1)
6. Suppose each set is represented as a linked list with elements in arbitrary order. Which of the
operations among union, intersection, membership, and cardinality will be the slowest?
7. Circularly linked list is used to represent a Queue. A single variable p is used to access the Queue. To
which node should p point such that both the operations enQueue and deQueue can be performed in
constant time?
8. Which of the following permutations can be obtained in the output (in the same order) using a stack
that the input is the sequence 1,2,3,4,5 in that order?
(A) 3,4,5,1,2
(B) 3,4,5,2,1
(C) 1,5,2,3,4
(D) 5,4,3,1,2
int temp;
while(q) {
temp = p → value;
p → value = q → value;
q → value = temp;
p = q → next;
q = p? p → next : 0;
(A) 1, 2, 3, 4, 5, 6, 7
(B) 2, 1, 4, 3, 6, 5, 7
(C) 1, 3, 2, 5, 4, 7, 6
(D) 2, 3, 4, 5, 6, 7, 1
11. Given linked list L with head pointing to the first node of L, shown bellow:
10->20->30->40->50.
What is the output when the following sequence of operation applied on the given linked list?
i) p= head->next->next->next;
ii) head->next=p;
iii) print(“%d”,head->next->next->data);
(A) 40 (B) 50 (C) 30 (D) 20
12. Which of the following operation is performed more efficient by DLL than by SLL?
13. Consider an implementation of unsorted SLL with head and tail pointer. Which of the following
operation can not be implemented in O(1) time.?