Explore topic-wise InterviewSolutions in .

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.

51.

Which of these operators have the highest order of precedence?(a) ‘(‘ and ‘)’(b) ‘*’ and ‘/’(c) ‘~’ and ‘^’(d) ‘+’ and ‘-‘Asked question is from Application of Stacks in section Application of Stacks of Data Structures & Algorithms II have been asked this question during a job interview.

Answer»

The correct ANSWER is (c) ‘~’ and ‘^’

To explain: The highest ORDER of precedence is ~ and ^ followed by ‘*’ ,’ /’, ‘+’ ,’-‘ andthen BRACES ‘(‘ ‘)’.

52.

In Postfix expressions, the operators come after the operands.(a) True(b) FalseMy doubt stems from Application of Stacks in section Application of Stacks of Data Structures & Algorithms II got this question during an interview.

Answer»

Right option is (a) True

Easiest EXPLANATION - In POSTFIX expressions, the OPERATORS FOLLOW operands. In prefix expressions, the operands follow operators.

53.

What is the time complexity of evaluation of postfix expression algorithm?(a) O (N)(b) O (N log N)(c) O (N^2)(d) O (M log N)Origin of the question is Application of Stacks in portion Application of Stacks of Data Structures & Algorithms IThe question was asked in homework.

Answer»

Correct CHOICE is (a) O (N)

The explanation is: The time complexity of evaluation of INFIX, prefix and postfix expressions is O (N).

54.

Reverse Polish Notation is the reverse of a Polish Notation.(a) True(b) FalseOrigin of the question is Application of Stacks topic in division Application of Stacks of Data Structures & Algorithms IThe question was posed to me during an interview.

Answer»

Correct answer is (b) False

The explanation is: Reverse Polish Notation is not the reverse of a polish notation. Though both NPN and RPN read the expression from LEFT to right, they FOLLOW different strategies.

55.

Which of the following is an example for a postfix expression?(a) a*b(c+d)(b) abc*+de-+(c) +ab(d) a+b-cMy question comes from Application of Stacks topic in chapter 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) abc*+de-+

For EXPLANATION: abc*+de-+ is a postfix expression. +ab is a PREFIX expression and OTHERS are infix expressions.

56.

What is the other name for a postfix expression?(a) Normal polish Notation(b) Reverse polish Notation(c) Warsaw notation(d) Infix notationMy enquiry is from Application of Stacks in division Application of Stacks of Data Structures & Algorithms IThis question was addressed to me during an interview.

Answer»

Correct ANSWER is (B) Reverse polish Notation

To explain: Reverse polish Notation is the other name for a postfix EXPRESSION whereas Polish Notation, Warsaw notation are the other names for a prefix expression.

57.

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=4The above asked question is from Application of Stacks in chapter Application of Stacks of Data Structures & Algorithms II had been asked this question in examination.

Answer»

The CORRECT option is (b) a=1, b=2, c=5, d=4

Easiest EXPLANATION - The given prefix expression is evaluated as ((1+2)*5)-4 = 11 while a=1, b=2, c=5, d=4.

58.

Using the evaluation of prefix algorithm, evaluate +-9 2 7.(a) 10(b) 4(c) 17(d) 14The question is from Application of Stacks in section Application of Stacks of Data Structures & Algorithms IThis question was addressed to me in an interview for job.

Answer» RIGHT choice is (d) 14

Easiest explanation - Using the EVALUATION of PREFIX ALGORITHM, +-9 2 7 is evaluated as 9-2+7=14.
59.

An error is thrown if the character ‘\n’ is pushed in to the character stack.(a) true(b) falseMy question comes from Application of Stacks topic in portion Application of Stacks of Data Structures & Algorithms II had been asked this question in a job interview.

Answer»

Correct answer is (b) false

The explanation is: The INPUT character ‘\n’ is accepted as a character by the evaluation of PREFIX expression algorithm.

60.

What determines the order of evaluation of a prefix expression?(a) precedence and associativity(b) precedence only(c) associativity only(d) depends on the parserQuestion is taken from Application of Stacks topic in section Application of Stacks of Data Structures & Algorithms IThis question was posed to me in an online quiz.

Answer»

Correct choice is (a) PRECEDENCE and associativity

The BEST I can explain: Precedence is a very important factor in determining the ORDER of evaluation. If two operators have the same precedence, associativity COMES into action.

61.

How many types of input characters are accepted by this algorithm?(a) one(b) two(c) three(d) fourMy doubt is from Application of Stacks topic in section Application of Stacks of Data Structures & Algorithms IThe question was posed to me in a job interview.

Answer»

Correct answer is (c) THREE

Explanation: Three kinds of input are accepted by this algorithm- NUMBERS, OPERATORS and new line CHARACTERS.

62.

The associativity of an exponentiation operator ^ is right side.(a) True(b) FalseEnquiry is from Application of Stacks topic in portion Application of Stacks of Data Structures & Algorithms IThis question was posed to me during an interview for a job.

Answer» CORRECT answer is (a) True

The best I can EXPLAIN: The ASSOCIATIVITY of ^ is right side while the REST of the operators like +,-,*,/ has its associativity to its left.
63.

While evaluating a prefix expression, the string is read from?(a) left to right(b) right to left(c) center to right(d) center to left to rightI'm obligated to ask this question of Application of Stacks topic in portion Application of Stacks of Data Structures & Algorithms II have been asked this question by my college professor while I was bunking the class.

Answer»

Right ANSWER is (b) right to left

Explanation: The STRING is READ from right to left because a prefix string has operands to its right SIDE.

64.

How many stacks are required for evaluation of prefix expression?(a) one(b) two(c) three(d) fourThe doubt is from Application of Stacks in section Application of Stacks of Data Structures & Algorithms IThe question was posed to me during a job interview.

Answer»

Correct choice is (B) two

The best EXPLANATION: 2 stacks are required for evaluation of PREFIX EXPRESSION, one for integers and one for characters.

65.

From the given expression tree, identify the infix expression, evaluate it and choose the correct result.(a) 5(b) 10(c) 12(d) 16This key question is from Evaluation of an Infix Expression (Not Parenthesized) in division Application of Stacks of Data Structures & Algorithms IThe question was posed to me during an interview.

Answer»

Correct answer is (c) 12

The explanation is: From the GIVEN EXPRESSION TREE, the result of the infix expression is evaluated to be 12.

66.

Evaluate the following infix expression using algorithm and choose the correct answer. a+b*c-d/e^fwhere a=1, b=2, c=3, d=4, e=2, f=2.(a) 6(b) 8(c) 9(d) 7This interesting question is from Evaluation of an Infix Expression (Not Parenthesized) in portion Application of Stacks of Data Structures & Algorithms IThis question was addressed to me during an interview.

Answer» CORRECT CHOICE is (a) 6

^ has the HIGHEST order of PRECEDENCE. Hence, 2^2 is evaluated FIRST, and then, 2*3 and 4/4 are evaluated. Therefore, 1+6-1=6.
67.

Using the evaluation of infix expression, evaluate a^b+cand choose the correct answer. (a=2, b=2, c=2)(a) 12(b) 8(c) 10(d) 6This question is from Evaluation of an Infix Expression (Not Parenthesized) 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»

Correct ANSWER is (d) 6

Easy EXPLANATION - ^ has the highest precedence. HENCE, 2^2 is EVALUATED and then 4+2 GIVES 6.

68.

Evaluate the following statement using infix evaluation algorithm and choose the correct answer. 4*2+3-5/5(a) 10(b) 11(c) 16(d) 12My question comes from Evaluation of an Infix Expression (Not Parenthesized) in chapter Application of Stacks of Data Structures & Algorithms IThe question was asked during an online interview.

Answer»

The correct option is (a) 10

The best I can explain: 4*2 and 5/5 are evaluated first and then, 8+3-1 is evaluated and the RESULT is OBTAINED as 10.

69.

The system throws an error if parentheses are encountered in an infix expression evaluation algorithm.(a) True(b) FalseThe origin of the question is Evaluation of an Infix Expression (Not Parenthesized) in portion Application of Stacks of Data Structures & Algorithms II got this question in an internship interview.

Answer»

Right option is (B) False

Best explanation: The algorithm holds good for INFIX EXPRESSION with parentheses. The SYSTEM does not throw error.

70.

Of the following choices, which operator has the lowest precedence?(a) ^(b) +(c) /(d) #I'm obligated to ask this question of Evaluation of an Infix Expression (Not Parenthesized) in division Application of Stacks of Data Structures & Algorithms IThe question was asked in examination.

Answer»

Correct ANSWER is (d) #

EASIEST EXPLANATION - The operator with the LOWEST precedence is #, PRECEDED by +, / and then ^.

71.

Evaluation of infix expression is done based on precedence of operators.(a) True(b) FalseMy doubt stems from Evaluation of an Infix Expression (Not Parenthesized) topic in division Application of Stacks of Data Structures & Algorithms IThe question was asked during an online interview.

Answer»

The correct choice is (a) True

Best explanation: During evaluation of INFIX expression, the operators with higher precedence are EVALUATED FIRST, followed by operators with LOWER precedence.

72.

Evaluate the following statement using infix evaluation algorithm and choose the correct answer. 1+2*3-2(a) 3(b) 6(c) 5(d) 4Asked question is from Evaluation of an Infix Expression (Not Parenthesized) topic in chapter Application of Stacks of Data Structures & Algorithms IThe question was asked in an internship interview.

Answer»

The correct option is (C) 5

The explanation is: ACCORDING to precedence of OPERATORS, * is EVALUATED first. + and – have equal priorities. Hence, 1+6-2= 5.

73.

Which of the following statement is incorrect with respect to evaluation of infix expression algorithm?(a) Operand is pushed on to the stack(b) If the precedence of operator is higher, pop two operands and evaluate(c) If the precedence of operator is lower, pop two operands and evaluate(d) The result is pushed on to the operand stackMy enquiry is from Evaluation of an Infix Expression (Not Parenthesized) topic in chapter Application of Stacks of Data Structures & Algorithms IThis question was posed to me in an interview.

Answer»

The CORRECT OPTION is (B) If the PRECEDENCE of operator is HIGHER, pop two operands and evaluate

The explanation is: If the precedence of the operator is higher than the stack operator, then it is pushed on to the stack operator.

74.

Identify the infix expression from the list of options given below.(a) a/b+(c-d)(b) abc*+d+ab+cd+*ce-f-(c) ab-c-(d) +abThis question is from Evaluation of an Infix Expression (Not Parenthesized) topic 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» RIGHT answer is (a) a/b+(c-d)

EASIEST explanation - a/b+(c-d) is an INFIX EXPRESSION since the operators are placed in between the operands.
75.

How many passes does the evaluation of infix expression algorithm makes through the input?(a) One(b) Two(c) Three(d) FourThis interesting question is from Evaluation of an Infix Expression (Not Parenthesized) topic in chapter Application of Stacks of Data Structures & Algorithms II got this question by my school principal while I was bunking the class.

Answer» RIGHT option is (a) One

The best I can explain: Evaluation of INFIX expression algorithm is LINEAR and MAKES only one pass through the input.
76.

How many stacks are required for applying evaluation of infix expression algorithm?(a) one(b) two(c) three(d) fourQuestion is taken from Evaluation of an Infix Expression (Not Parenthesized) in portion Application of Stacks of Data Structures & Algorithms IThe question was asked in homework.

Answer»

Correct answer is (b) TWO

Best explanation: Two STACKS are required for evaluation of infix EXPRESSION – one for OPERANDS and one for OPERATORS.