3,410 views
1 votes
1 votes
  • If arity of operators is fixed, then which of the following notations can be used to parse expressions without parentheses? a) Infix Notation (Inorder traversal of a expression tree) b) Postfix Notation (Postorder traversal of a expression tree) c) Prefix Notation (Preorder traversal of a expression tree)

    A

    b and c

    B

    Only b

    C

    a, b and c

    D

    None of them

    What arity of operators?

2 Answers

1 votes
1 votes
Ans.-option a

Consider inorder traversal or infix as

a+b*c+d*e+f+g

its prefix is

++a*bc++*defg

And postfix expression is

abc*++de*f+g++

Here prefix and postfix can be calculated in right way by using algorithms. [Arity for each operator is given].But inorder can give different values.
0 votes
0 votes
arity means the number of operands that an operator works on e.g. arithmetic operators are binary i.e. they can be applied on two operands simultaneously 4+2,9*4 etc

here question is if arity is fixed how can we evaluate an expression correctly if it does not have parenthesis.

By the help of parenthesis we give evaluate expression by precedence by using precedence rules.

we don't have any algorithm which can evaluate infix expressions without parenthesis as it can give different results but for postfix and prefix we have algorithms which directly solve them.

So answer is A i.e. only Postfix and prefix notations can be used.

Related questions

2 votes
2 votes
1 answer
2
Rishav Kumar Singh asked Jun 15, 2018
2,886 views
Which data structure is most efficient to find the top 10 largest items out of 1 million items stored in file?AMin heapBMax heapCBSTDSorted array
0 votes
0 votes
1 answer
4
atulcse asked Jan 15, 2022
679 views
How many minimum relations are required for the following Relation R(A, B, C, D, E) with FD {A → BC, CD → E, B → D, E → A} to convert into BCNF without violation ...