

MCQOPTIONS
Saved Bookmarks
This section includes 66 Mcqs, each offering curated multiple-choice questions to sharpen your Data Structures and Algorithms knowledge and support exam preparation. Choose a topic below to get started.
1. |
Which of the following is an example for a postfix expression? |
A. | a*b(c+d) |
B. | abc*+de |
C. | +ab |
D. | a+b-c |
Answer» C. +ab | |
2. |
An error is thrown if the character '\n' is pushed in to the character stack. |
A. | true |
B. | false |
Answer» C. | |
3. |
How many passes does the balancing symbols algorithm makes through the input? |
A. | one |
B. | two |
C. | three |
D. | four |
Answer» B. two | |
4. |
The postfix expression abc+de/*- is equivalent to which of the following infix expression |
A. | abc+-de*/ |
B. | (a+b)-d/e*c |
C. | a-(a+b)*(d/e) |
D. | abc+*-(d/e) |
Answer» D. abc+*-(d/e) | |
5. |
When the corresponding end bracket/braces/parentheses is not found, what happens? |
A. | The stack is popped |
B. | Ignore the parentheses |
C. | An error is reported |
D. | It is treated as an exception |
Answer» D. It is treated as an exception | |
6. |
What is the value of the postfix expression 2 3 + 4 5 6 – – * |
A. | 19 |
B. | 21 |
C. | 23 |
D. | -2 |
Answer» C. 23 | |
7. |
If -*+abcd = 11, find a, b, c, d using evaluation of prefix algorithm. |
A. | a=2, b=3, c=5, d=4 |
B. | a=1, b=2, c=5, d=4 |
C. | a=5, b=4, c=7,d=5 |
D. | a=1, b=2, c=3, d=4 |
Answer» C. a=5, b=4, c=7,d=5 | |
8. |
In Postfix expressions, the operators come after the operands. |
A. | True |
B. | False |
Answer» B. False | |
9. |
What should be done when a left parenthesis '(' is encountered? |
A. | It is ignored |
B. | It is placed in the output |
C. | It is placed in the operator stack |
D. | The contents of the operator stack is emptied |
Answer» D. The contents of the operator stack is emptied | |
10. |
What determines the order of evaluation of a prefix expression? |
A. | precedence and associativity |
B. | precedence only |
C. | associativity only |
D. | depends on the parser |
Answer» B. precedence only | |
11. |
Using the evaluation of prefix algorithm, evaluate +-9 2 7. |
A. | 10 |
B. | 4 |
C. | 17 |
D. | 14 |
Answer» E. | |
12. |
Reverse Polish Notation is the reverse of a Polish Notation |
A. | True |
B. | False |
Answer» C. | |
13. |
When converting the prefix notation into an infix notation, the first step to be followed is ________ |
A. | Reverse the equation |
B. | Push the equation to the stack |
C. | Push the equation onto the queue |
D. | Push the equation to the stack or queue |
Answer» B. Push the equation to the stack | |
14. |
How many stacks are required for evaluation of prefix expression? |
A. | one |
B. | two |
C. | three |
D. | four |
Answer» C. three | |
15. |
How many types of input characters are accepted by this algorithm? |
A. | one |
B. | two |
C. | three |
D. | four |
Answer» D. four | |
16. |
What is the time complexity of balancing parentheses algorithm? |
A. | O (N) |
B. | O (N log N) |
C. | O (M log N) |
D. | O (N2) |
Answer» B. O (N log N) | |
17. |
Which of the following is not an application of stack? |
A. | evaluation of postfix expression |
B. | conversion of infix to postfix expression |
C. | balancing symbols |
D. | line at ticket counter |
Answer» E. | |
18. |
What will be the word obtained if the word 'abbcabb' is reversed using a stack? |
A. | bbabbca |
B. | abbcabb |
C. | bbacbba |
D. | bbacabb |
Answer» D. bbacabb | |
19. |
The result of the postfix expression 5 3 * 9 + 6 / 8 4 / + is |
A. | 8 |
B. | 6 |
C. | 10 |
D. | 9 |
Answer» C. 10 | |
20. |
If the corresponding end bracket/braces/parentheses is encountered, which of the following is done? |
A. | push it on to the stack |
B. | pop the stack |
C. | throw an error |
D. | treated as an exception |
Answer» C. throw an error | |
21. |
The equivalent infix expression and value for the postfix form 1 2 + 3 * 4 5 * – will be |
A. | 1 + 2 * 3 – 4 * 5 and -13 |
B. | (2 + 1) * (3 – 4) * 5 and 13 |
C. | 1 + 2 * (3 – 4) * 5 and -11 |
D. | (1 + 2) * 3 – (4 * 5) and -11 |
Answer» E. | |
22. |
Given two processes (conversion of postfix equation to infix notation and conversion of prefix notation to infix notation), which of the following is easier to implement? |
A. | Both are easy to implement |
B. | Conversion of postfix equation to infix equation is harder than converting a prefix notation to infix notation |
C. | Conversion of postfix equation to infix equation is easier than converting a prefix notation to infix notation |
D. | Insufficient data |
Answer» D. Insufficient data | |
23. |
What data structure is used when converting an infix notation to prefix notation? |
A. | Stack |
B. | Queue |
C. | B-Trees |
D. | Linked-list |
Answer» B. Queue | |
24. |
The prefix expression of the postfix expression AB+CD-* is |
A. | (A+B)*(C-D) |
B. | +AB*-CD |
C. | A+*BCD- |
D. | *+AB-CD |
Answer» E. | |
25. |
Which application of stack is used to ensure that the pair of parentheses is properly nested? |
A. | Balancing symbols |
B. | Reversing a stack |
C. | Conversion of an infix to postfix expression |
D. | Conversion of an infix to prefix expression |
Answer» B. Reversing a stack | |
26. |
The associativity of an exponentiation operator ^ is right side. |
A. | True |
B. | False |
Answer» B. False | |
27. |
Which of the following does the balancing symbols algorithm include? |
A. | balancing double quotes |
B. | balancing single quotes |
C. | balancing operators and brackets |
D. | balancing parentheses, brackets and braces |
Answer» E. | |
28. |
In balancing parentheses algorithm, the string is read from? |
A. | right to left |
B. | left to right |
C. | center to right |
D. | center to left |
Answer» C. center to right | |
29. |
Evaluate the postfix expression ab + cd/- where a=5, b=4, c=9, d=3. |
A. | 23 |
B. | 15 |
C. | 6 |
D. | 10 |
Answer» D. 10 | |
30. |
In infix to postfix conversion algorithm, the operators are associated from? |
A. | right to left |
B. | left to right |
C. | centre to left |
D. | centre to right |
Answer» C. centre to left | |
31. |
Which of the following statement is invalid with respect to balancing symbols? |
A. | [(A+B) + (C-D)] |
B. | [{A+B}-{C-[D+E]}] |
C. | ((A+B) + (C+D) |
D. | {(A+B) + [C+D]} |
Answer» D. {(A+B) + [C+D]} | |
32. |
It is easier for a computer to process a postfix expression than an infix expression. |
A. | True |
B. | False |
Answer» B. False | |
33. |
While evaluating a postfix expression, when an operator is encountered, what is the correct operation to be performed? |
A. | push it directly on to the stack |
B. | pop 2 operands, evaluate them and push the result on to the stack |
C. | pop the entire stack |
D. | ignore the operator |
Answer» C. pop the entire stack | |
34. |
Which is the most appropriate data structure for applying balancing of symbols algorithm? |
A. | stack |
B. | queue |
C. | tree |
D. | graph |
Answer» B. queue | |
35. |
Is the given statement ((A+B) + [C-D]] valid with respect to balancing of symbols? |
A. | True |
B. | False |
Answer» C. | |
36. |
What should be done when an opening parentheses is read in a balancing symbols algorithm? |
A. | push it on to the stack |
B. | throw an error |
C. | ignore the parentheses |
D. | pop the stack |
Answer» B. throw an error | |
37. |
Which of the following statement is incorrect with respect to infix to postfix conversion algorithm? |
A. | operand is always placed in the output |
B. | operator is placed in the stack when the stack operator has lower precedence |
C. | parenthesis are included in the output |
D. | higher and equal priority operators follow the same condition |
Answer» D. higher and equal priority operators follow the same condition | |
38. |
What will be output if the following sequence of operations are executed?Push(a,s);Push(b,s);Pop(b);Push(c,s); |
A. | abc |
B. | b |
C. | ac |
D. | acb |
Answer» C. ac | |
39. |
Consider the postfix expression 4 5 6 a b 7 8 a c, where a, b, c are operators. Operator a has higher precedence over operators b and c. Operators b and c are right associative. Then, equivalent infix expression is |
A. | 4 a 5 6 b 7 8 a c |
B. | 4 a 5 c 6 b 7 a 8 |
C. | 4 b 5 a 6 c 7 a 8 |
D. | 4 a 5 b 6 c 7 a 8 |
Answer» D. 4 a 5 b 6 c 7 a 8 | |
40. |
The time complexity of converting a prefix notation to infix notation is _________ |
A. | O(n) where n is the length of the equation |
B. | O(n) where n is number of operands |
C. | O(1) |
D. | O(logn) where n is length of the equation |
Answer» B. O(n) where n is number of operands | |
41. |
Which of the following is an infix expression? |
A. | (a+ |
B. | *(c+d)b) ab+c* |
C. | +ab |
D. | abc+* |
Answer» B. *(c+d)b) ab+c* | |
42. |
What is the time complexity of the above code? |
A. | O(logn) |
B. | O(n) |
C. | O(1) |
D. | O(nlogn) |
Answer» C. O(1) | |
43. |
Find the output of the following prefix expression*+2-2 1/-4 2+-5 3 1 |
A. | 2 |
B. | 12 |
C. | 10 |
D. | 4 |
Answer» B. 12 | |
44. |
What is the number of moves required in the Tower of Hanoi problem for k disks? |
A. | 2k – 1 |
B. | 2k + 1 |
C. | 2k + 1 |
D. | 2k – 1 |
Answer» E. | |
45. |
What is the time complexity of evaluation of postfix expression algorithm? |
A. | O (N) |
B. | O (N log N) |
C. | O (N2) |
D. | O (M log N) |
Answer» B. O (N log N) | |
46. |
An error is reported when the stack is not empty at the end. |
A. | True |
B. | False |
Answer» B. False | |
47. |
Evaluate and write the result for the following postfix expression abc*+de*f+g*+ where a=1, b=2, c=3, d=4, e=5, f=6, g=2. |
A. | 61 |
B. | 59 |
C. | 60 |
D. | 55 |
Answer» C. 60 | |
48. |
Express -15 as a 6-bit signed binary number. |
A. | 1111 |
B. | 101111 |
C. | 101110 |
D. | 1110 |
Answer» C. 101110 | |
49. |
Consider the stack| 5 || 4 || 3 || 2 |.At this point, '*' is encountered. What has to be done? |
A. | 5*4=20 is pushed into the stack |
B. | * is pushed into the stack |
C. | 2*3=6 is pushed into the stack |
D. | * is ignored |
Answer» B. * is pushed into the stack | |
50. |
Which of the following data structure is used to convert postfix expression to infix expression? |
A. | Stack |
B. | Queue |
C. | Linked List |
D. | Heap |
Answer» B. Queue | |