InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
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]}The question is from Application of Stacks topic in chapter Application of Stacks of Data Structures & Algorithms IThis question was posed to me in an interview for job. |
|
Answer» RIGHT answer is (C) ((A+B) + (C+D) The best explanation: ((A+B) + (C+D) is invalid because the last close brace is not FOUND in the STATEMENT. |
|
| 2. |
How many passes does the balancing symbols algorithm makes through the input?(a) one(b) two(c) three(d) fourMy doubt stems from Application of Stacks topic in chapter Application of Stacks of Data Structures & Algorithms IThe question was asked in an interview for job. |
|
Answer» Correct choice is (a) one |
|
| 3. |
Is the given statement ((A+B) + [C-D]] valid with respect to balancing of symbols?(a) True(b) FalseThis key question is from Application of Stacks in division Application of Stacks of Data Structures & Algorithms IThe question was asked in an interview for job. |
|
Answer» Correct CHOICE is (b) False |
|
| 4. |
An error is reported when the stack is not empty at the end.(a) True(b) FalseI need to ask this question from Application of Stacks topic in portion Application of Stacks of Data Structures & Algorithms II have been asked this question in an internship interview. |
|
Answer» The correct option is (a) True |
|
| 5. |
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 exceptionThis interesting question is from Application of Stacks topic in section Application of Stacks of Data Structures & Algorithms IThe question was posed to me during an interview. |
|
Answer» Right option is (b) pop the STACK |
|
| 6. |
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 exceptionMy question is taken from Application of Stacks topic in division Application of Stacks of Data Structures & Algorithms II have been asked this question in class test. |
|
Answer» CORRECT option is (C) An ERROR is reported Best explanation: When the corresponding END bracket/braces/parentheses is not found, throw an error since they don’t match. |
|
| 7. |
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 stackQuestion is from Application of Stacks in section Application of Stacks of Data Structures & Algorithms IThis question was addressed to me in my homework. |
|
Answer» The correct answer is (a) push it on to the stack |
|
| 8. |
Which of the following statement is incorrect with respect to balancing symbols algorithm?(a) {[()]}(b) ([ )](c) {( )}(d) { [ ] }The query is from Application of Stacks topic in chapter Application of Stacks of Data Structures & Algorithms II got this question by my school teacher while I was bunking the class. |
|
Answer» CORRECT OPTION is (B) ([ )] For explanation: ([ )] is INCORRECT because’)’ occurs before the corresponding ‘]’ is encountered. |
|
| 9. |
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 bracesThe doubt is from Application of Stacks in portion Application of Stacks of Data Structures & Algorithms IThis question was addressed to me in class test. |
|
Answer» RIGHT choice is (d) balancing parentheses, BRACKETS and BRACES Easiest explanation - The balancing symbols ALGORITHM using STACK only includes balancing parentheses, brackets and braces and not any other symbols. |
|
| 10. |
Which is the most appropriate data structure for applying balancing of symbols algorithm?(a) stack(b) queue(c) tree(d) graphI want to ask this question from Application of Stacks topic in portion Application of Stacks of Data Structures & Algorithms II had been asked this question in homework. |
|
Answer» The correct answer is (a) stack |
|
| 11. |
In balancing parentheses algorithm, the string is read from?(a) right to left(b) left to right(c) center to right(d) center to leftThis interesting question is from Application of Stacks in section Application of Stacks of Data Structures & Algorithms II got this question by my school teacher while I was bunking the class. |
|
Answer» Correct option is (B) left to right |
|
| 12. |
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 expressionQuery is from Application of Stacks in portion Application of Stacks of Data Structures & Algorithms IThe question was posed to me in homework. |
|
Answer» RIGHT choice is (a) Balancing symbols Easy explanation - Balancing symbols APPLICATION ensures that the pair of parentheses are PROPERLY NESTED while reversing stack REVERSES a stack. |
|
| 13. |
What is the time complexity of balancing parentheses algorithm?(a) O (N)(b) O (N log N)(c) O (M log N)(d) O (N^2)I need to ask this question from Application of Stacks topic in portion Application of Stacks of Data Structures & Algorithms II had been asked this question by my college professor while I was bunking the class. |
|
Answer» The correct choice is (a) O (N) |
|
| 14. |
What will be result if the given stack is popped?(a) pat(b) tap(c) atp(d) aptThis interesting question is from Reverse a Word using Stack in chapter Application of Stacks of Data Structures & Algorithms IThe question was asked in my homework. |
|
Answer» The correct CHOICE is (b) TAP |
|
| 15. |
How many stacks are required for reversing a word algorithm?(a) one(b) two(c) three(d) fourMy query is from Reverse a Word using Stack in chapter Application of Stacks of Data Structures & Algorithms II got this question in homework. |
|
Answer» The CORRECT OPTION is (a) one |
|
| 16. |
What will be the word obtained if the word “abbcabb” is reversed using a stack?(a) bbabbca(b) abbcabb(c) bbacbba(d) bbacabbI want to ask this question from Reverse a Word using Stack topic in chapter Application of Stacks of Data Structures & Algorithms IThis question was posed to me during an online exam. |
|
Answer» Correct ANSWER is (C) bbacbba |
|
| 17. |
What is the time complexity of reversing a word using stack algorithm?(a) O (N log N)(b) O (N^2)(c) O (N)(d) O (M log N)I want to ask this question from Reverse a Word using Stack in chapter Application of Stacks of Data Structures & Algorithms II had been asked this question in class test. |
|
Answer» Correct CHOICE is (C) O (N) |
|
| 18. |
Operations required for reversing a word or a string using stack are push() andpop().(a) True(b) FalseMy doubt is from Reverse a Word using Stack in portion Application of Stacks of Data Structures & Algorithms IThe question was posed to me in quiz. |
|
Answer» RIGHT option is (a) True Explanation: PUSH operation inserts a CHARACTER into the stack and pop operation POPS the top of the stack. |
|
| 19. |
Which is the most appropriate data structure for reversing a word?(a) queue(b) stack(c) tree(d) graphI'm obligated to ask this question of Reverse a Word using Stack topic in division Application of Stacks of Data Structures & Algorithms IThis question was addressed to me by my college director while I was bunking the class. |
|
Answer» RIGHT choice is (b) stack Best EXPLANATION: Stack is the most appropriate data structure for REVERSING a word because stack FOLLOWS LIFO principle. |
|
| 20. |
Reversing a word using stack can be used to find if the given word is a palindrome or not.(a) True(b) FalseQuestion is taken from Reverse a Word using Stack in portion Application of Stacks of Data Structures & Algorithms II had been asked this question in final exam. |
|
Answer» Right choice is (a) True |
|
| 21. |
The result of the postfix expression 5 3 * 9 + 6 / 8 4 / + is _____________(a) 8(b) 6(c) 10(d) 9My doubt is from Application of Stacks in division Application of Stacks of Data Structures & Algorithms II have been asked this question in an interview. |
|
Answer» Right option is (b) 6 |
|
| 22. |
Which of the following is valid reverse polish expression?(a) a op b(b) op a b(c) a b op(d) both op a b and a b opThis interesting question is from Application of Stacks topic in chapter Application of Stacks of Data Structures & Algorithms IThis question was posed to me during a job interview. |
|
Answer» The correct CHOICE is (c) a b op |
|
| 23. |
To convert the postfix expression into the infix expression we use stack and scan the postfix expression from left to right.(a) True(b) FalseMy question is from Application of Stacks in division Application of Stacks of Data Structures & Algorithms IThe question was asked in a national level competition. |
|
Answer» The correct option is (a) True |
|
| 24. |
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 6b 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 8This intriguing question comes from Application of Stacks topic in chapter Application of Stacks of Data Structures & Algorithms II had been asked this question during an online exam. |
|
Answer» Correct choice: (c) 4 b 5 a 6 c 7 a 8 Given POSTFIX EXPRESSION: 4 5 6 a b 7 8 a c INFIX ⇒ 4 (5 a 6)b (7 a 8)c ⇒ (4 b (5 a 6)) (7 a 8)c ⇒ (4 b (5 a 6)) c (7 a 8) So, the required infix expression is 4 b 5 a 6 c 7 a 8. |
|
| 25. |
The prefix expression of the postfix expression AB+CD-* is __________(a) (A+B)*(C-D)(b) +AB*-CD(c) A+*BCD-(d) *+AB-CDThe doubt is from Application of Stacks in portion Application of Stacks of Data Structures & Algorithms II had been asked this question in an online quiz. |
|
Answer» CORRECT answer is (d) *+AB-CD To explain: To CONVERT from postfix to PREFIX, we FIRST convert it to infix and then to prefix. postfix :AB+CD-* infix ⇒ (A+B) * (C-D) So,prefix ⇒ +AB*-CD, |
|
| 26. |
What is the value of the postfix expression2 3 + 4 5 6 – – *(a) 19(b) 21(c) -4(d) 25This key question is from Application of Stacks in portion Application of Stacks of Data Structures & Algorithms IThe question was asked during an internship interview. |
|
Answer» CORRECT option is (d) 25 The best EXPLANATION: Given postfix expression : 2 3 + 4 5 6 – – * infix ⇒ (2 + 3)4 (5 – 6) – * ⇒ (2 + 3)*4 – (5 – 6) Hence, VALUE = (2 + 3) * (4 – (5 – 6)) = 5 *(4 – (-1)) = 5*5 = 25. |
|
| 27. |
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 -11My doubt stems from Application of Stacks topic in chapter Application of Stacks of Data Structures & Algorithms II have been asked this question in an interview for job. |
|
Answer» CORRECT answer is (d) (1 + 2) * 3 – (4 * 5) and -11 Given postfix expression : 1 2 + 3 * 4 5 * – ⇒ (1 + 2) 3 * 4 5 * – ⇒ ((1 + 2) * 3) 4 5 * – ⇒ ((1 + 2) * 3) (4 * 5) – ⇒ ((1 + 2) * 3) – (4 * 5) So, the equivalent infix expression is (1 + 2) * 3 – (4 * 5) and it’s VALUE is -11. |
|
| 28. |
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-(b+c)*(d/e)(d) abc+*-(d/e)My enquiry is from Application of Stacks in chapter Application of Stacks of Data Structures & Algorithms II have been asked this question during a job interview. |
|
Answer» Right answer is (C) a-(b+c)*(d/e) |
|
| 29. |
Which of the following data structure is used to convert postfix expression to infix expression?(a) Stack(b) Queue(c) Linked List(d) HeapMy query is from Application of Stacks in section Application of Stacks of Data Structures & Algorithms IThis question was addressed to me in a national level competition. |
|
Answer» CORRECT option is (a) Stack Best EXPLANATION: To convert the POSTFIX expression into INFIX expression we need stack. We need stack to maintain the intermediate infix expressions. We use stack to hold operands. |
|
| 30. |
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 dataThe origin of the question is Application of Stacks in portion Application of Stacks of Data Structures & Algorithms IThe question was posed to me in unit test. |
|
Answer» The correct choice is (c) Conversion of POSTFIX equation to INFIX equation is easier than CONVERTING a prefix notation to infix notation |
|
| 31. |
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 equationQuestion is taken from Application of Stacks in section Application of Stacks of Data Structures & Algorithms IThe question was posed to me in a national level competition. |
|
Answer» The correct ANSWER is (a) O(n) where n is the LENGTH of the equation |
|
| 32. |
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 queueThis intriguing question comes from Application of Stacks topic in portion Application of Stacks of Data Structures & Algorithms IThe question was posed to me in a job interview. |
|
Answer» The correct choice is (a) Reverse the equation |
|
| 33. |
Given a prefix and a postfix notation what are the difference between them?(a) The postfix equation is solved starting from the left whereas the prefix notation is solved from the right(b) The postfix equation is solved starting from the right whereas the prefix notation is solved from the left(c) Both equations are solved starting from the same side(right)(d) Both equations are solved starting from the same side(left)My question is from Application of Stacks in section Application of Stacks of Data Structures & Algorithms II got this question by my college director while I was bunking the class. |
|
Answer» Right option is (a) The POSTFIX EQUATION is solved STARTING from the left whereas the prefix NOTATION is solved from the right |
|
| 34. |
From the given Expression tree, identify the correct postfix expression from the list of options.(a) ab*cd*+(b) ab*cd-+(c) abcd-*+(d) ab*+cd-The origin of the question is Application of Stacks in division Application of Stacks of Data Structures & Algorithms IThis question was posed to me in semester exam. |
|
Answer» The correct option is (b) ab*cd-+ |
|
| 35. |
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 rightThe above asked question is from Application of Stacks topic in section Application of Stacks of Data Structures & Algorithms II have been asked this question by my school principal while I was bunking the class. |
|
Answer» The correct option is (b) left to right |
|
| 36. |
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 conditionMy question is from Application of Stacks in division Application of Stacks of Data Structures & Algorithms IThis question was posed to me during a job interview. |
|
Answer» RIGHT choice is (c) parenthesis are INCLUDED in the OUTPUT The BEST I can explain: Parentheses are not included in the output. They are placed in the operator stack and then discarded. |
|
| 37. |
It is easier for a computer to process a postfix expression than an infix expression.(a) True(b) FalseOrigin of the question is Application of Stacks topic in section Application of Stacks of Data Structures & Algorithms IThe question was asked in quiz. |
|
Answer» Right ANSWER is (a) True |
|
| 38. |
Parentheses are simply ignored in the conversion of infix to postfix expression.(a) True(b) FalseOrigin of the question is Application of Stacks in chapter Application of Stacks of Data Structures & Algorithms II got this question by my college professor while I was bunking the class. |
|
Answer» The CORRECT OPTION is (b) False |
|
| 39. |
What is the time complexity of an infix to postfix conversion algorithm?(a) O(N log N)(b) O(N)(c) O(N^2)(d) O(M log N)This is a very interesting question from Application of Stacks in portion Application of Stacks of Data Structures & Algorithms IThis question was addressed to me in unit test. |
|
Answer» CORRECT choice is (b) O(N) The best I can explain: The TIME complexity of an infix to POSTFIX EXPRESSION conversion algorithm is mathematically found to be O(N). |
|
| 40. |
Which of the following is an infix expression?(a) (a+b)*(c+d)(b) ab+c*(c) +ab(d) abc+*The above asked question is from Application of Stacks in section Application of Stacks of Data Structures & Algorithms II had been asked this question by my school principal while I was bunking the class. |
|
Answer» CORRECT ANSWER is (a) (a+b)*(c+d) BEST explanation: (a+b)*(c+d) is an infix expression. +AB is a prefix expression and ab+c* is a POSTFIX expression. |
|
| 41. |
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 emptiedMy question comes from Application of Stacks in section Application of Stacks of Data Structures & Algorithms IThe question was posed to me in my homework. |
|
Answer» The correct choice is (C) It is placed in the OPERATOR stack |
|
| 42. |
Out of the following operators (|, *, +, &), the one having lowest priority is ________(a) +(b) *(c) |(d) &I would like to ask this question from Application of Stacks in chapter Application of Stacks of Data Structures & Algorithms IThe question was posed to me in an interview for an internship. |
|
Answer» Correct option is (c) | |
|
| 43. |
Out of the following operators (^, *, +, &), the one having highest priority is _________(a) +(b) *(c) ^(d) &My enquiry is from Application of Stacks in chapter Application of Stacks of Data Structures & Algorithms II have been asked this question in quiz. |
|
Answer» The CORRECT choice is (c) ^ |
|
| 44. |
What data structure is used when converting an infix notation to prefix notation?(a) Stack(b) Queue(c) B-Trees(d) Linked-listMy question is based upon Application of Stacks in division Application of Stacks of Data Structures & Algorithms II got this question during an interview for a job. |
|
Answer» Right choice is (a) Stack |
|
| 45. |
For the given expression tree, write the correct postfix expression.(a) abc*+(b) abc+*(c) ab+c*(d) a+bc*I want to ask this question from Application of Stacks topic in section Application of Stacks of Data Structures & Algorithms IThis question was addressed to me during an interview for a job. |
|
Answer» CORRECT answer is (a) ABC*+ To explain: EVALUATING the given expression TREE GIVES the infix expression a+b*c. Converting it to postfix, we get, abc*+. |
|
| 46. |
Evaluate the postfix expression ab + cd/- where a=5, b=4, c=9, d=3.(a) 23(b) 15(c) 6(d) 10Question is from Application of Stacks in portion Application of Stacks of Data Structures & Algorithms IThis question was addressed to me by my college director while I was bunking the class. |
|
Answer» Correct choice is (C) 6 |
|
| 47. |
What is the result of the given postfix expression?abc*+ where a=1, b=2, c=3.(a) 4(b) 5(c) 6(d) 7I need to ask this question from Application of Stacks topic in chapter Application of Stacks of Data Structures & Algorithms IThe question was asked in examination. |
|
Answer» RIGHT OPTION is (d) 7 Best EXPLANATION: The infix EXPRESSION is a+b*c. Evaluating it, we get 1+2*3=7. |
|
| 48. |
Which of the following statement is incorrect?(a) Postfix operators use value to their right(b) Postfix operators use value to their left(c) Prefix operators use value to their right(d) In postfix expression, operands are followed by operatorsQuestion is from Application of Stacks in section Application of Stacks of Data Structures & Algorithms IThis question was addressed to me in an interview for internship. |
|
Answer» Correct choice is (a) Postfix operators use VALUE to their RIGHT |
|
| 49. |
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 operatorThis question is from Application of Stacks topic in section Application of Stacks of Data Structures & Algorithms II had been asked this question in homework. |
|
Answer» Right CHOICE is (B) pop 2 OPERANDS, evaluate them and push the result on to the stack |
|
| 50. |
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 counterMy doubt is from Application of Stacks topic in portion Application of Stacks of Data Structures & Algorithms II have been asked this question by my school principal while I was bunking the class. |
|
Answer» The correct answer is (d) LINE at ticket COUNTER |
|