DSA MCQs
DSA MCQs
Page 2 of 4
while(fast -> next != NULL && fast -> next -> next != NULL) {
fast = fast -> next -> next;
slow = slow -> next;
}
return slow -> data;
}
(a) Find middle element in the linked list (b) Find last element in the
linked list (c) Find first element in the linked list (d) None of these
What is the optimal time complexity to count the number of nodes
24 in a linked list? (a) O(n)
(a) O(n) (b) O(1) (c) O(log n) (d) None of these
A stack holding elements equal to its capacity and if push is
performed then such situation is called (a) stack
25
(a) stack overflow (b) stack underflow (c) illegal operation overflow
(d) None of the above.
The postfix expression corresponding to the infix expression a + b ×
c - d ^ e ^ f is (a) abc × + def
26
(a) abc × + def ^ ^ - (b) abc × + de ^ f ^ - (c) ab + c × d - e ^ f ^ ^^-
(d) - + a × bc ^ ^ def
To evaluate an expression without any embedded function calls :
(a) As many stacks as the height of the expression tree are needed (b) One stack
27
(b) One stack is enough (c) Two stacks are needed (d) A Turing is enough
machine is needed in the general case
The result evaluating the postfix expression 10 5 + 60 6 / * 8 – is
28 (c) 142
(a) 284 (b) 213 (c) 142 (d) 71
Which of the following permutation can be obtained in the same
order using a stack assuming that input is the sequence 5, 6, 7, 8,
29 (c) 7, 8, 9, 6, 5
9 in that order?
(a) 7, 8, 9, 5, 6 (b) 5, 9, 6, 7, 8 (c) 7, 8, 9, 6, 5 (d) 9, 8, 7, 5, 6
The best data structure to check whether an arithmetic expression
30 has balanced parenthesis is a (b) Stack
(a) Queue (b) Stack (c) Tree (d) List
31 (a) (b) (c) (d)
32 (a) (b) (c) (d)
33 (a) (b) (c) (d)
34 (a) (b) (c) (d)
35 (a) (b) (c) (d)
36 (a) (b) (c) (d)
37 (a) (b) (c) (d)
38 (a) (b) (c) (d)
39 (a) (b) (c) (d)
40 (a) (b) (c) (d)
41 (a) (b) (c) (d)
42 (a) (b) (c) (d)
43 (a) (b) (c) (d)
Page 3 of 4
44 (a) (b) (c) (d)
45 (a) (b) (c) (d)
46 (a) (b) (c) (d)
47 (a) (b) (c) (d)
48 (a) (b) (c) (d)
49 (a) (b) (c) (d)
50 (a) (b) (c) (d)
Page 4 of 4