Basically Parenthesis indicate the operations which
need to be carried out first ie according to the
BODMAS rule..SO in case of postfix or prefix expression
they are actualy conversions of the orginal standard
equation.Where the brackets have already been taken
into consideration,,,and the formed prefix/postfix
expression is the correct order of expansion of a given
mathematical statement..
in a prefix or postfix notation there is not anything
related to preority of operators and only we have to moov
from one side to nother so brackets are not required.
Evaluation of postfix or prefix notations are done with the
help of stacks. So there is no need for brackets.
In other words, infix notation is human-readable format,
which need brackets based on BODMAS rule to understand the
order of execution. The postfix or prefix are
machine-readable format. The conversion and evaluation of
postfix and prefix are applications of stack model.
Parenthesis are used to define the sequence or priority of
execution of operations in given infix expression. When we
write an espression in prefix or postfix format we have
already considered the order of execution and only evaluate
the expression starting from left towars right in the
sequence the operators and operands are encountered.
Parenthesis are used to define the sequence or priority of
execution of operations which is useful in infix notation.
Whereas we have already taken
the consideration of order of execution of operands during
the time of conversion to
prefix or postfix form.These orders are maintained with
the help of Stack
i.e. Last in First out. So we donot need parenthesis in
prefix and postfix notions.
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?
The element being searched for is not found in an array of
100 elements. What is the average number of comparisons
needed in a sequential search to determine that the element
is not there, if the elements are completely unordered?
What is the average number of comparisons needed in a
sequential search to determine the position of an element in
an array of 100 elements, if the elements are ordered from
largest to smallest?