Parenthesis are never needed in prefix or postfix
expressions. Why?
Answer Posted / soumya kanti
In case of infix expression, the entry point of the
execution can be either left or right (forget about operator
priority).
Evaluate 2+3*5 from left, it is 30; from right, it is 17.
Convert it to postfix, 235*+, no confusion about the entry
point (and the answer which is 30). If we made it mandatory
for infix expression also that the entry point of evaluation
will be from left, there will not be any need for
parentheses. 2+3*5 will always be 30, to make it 17 write it
as 3*5+2 (in postfix).
Unfortunately, this rule for infix expression is not
mandated when first human mathematicians started thinking
(in early days of civilization). And alas, no common man
will accept this rule if I go to thrust it upon them. So we
have to live with parentheses in infix, and thankfully, none
in prefix or postfix. Machines are more logical being than
human. Agree?
| Is This Answer Correct ? | 8 Yes | 12 No |
Post New Answer View All Answers
What are the advantages of array?
What is difference between linear and non linear data structure?
What method removes the value from the top of a stack?
How do you use merge sort?
Define a path in a tree?
What are dynamic data structures?
What is list and types of list?
Can hashmap store null values?
What is immutablelist?
Which is faster hashmap or hashset?
Write the syntax in c to create a node in the singly linked list.
Can you distinguish between ArrayList and Array?
Is char array null terminated?
What is array simple?
Differentiate between arraylist and linkedlist.