10.09.2013 Views

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

LECTURE NOTES OF ADVANCED DATA STRUCTURE (MT-CSE 110)<br />

A * B + C / D A B * C D / + + * A B / C D<br />

A * (B + C) / D A B C + * D / / * A + B C D<br />

A * (B + C / D) A B C D / + * * A + B / C D<br />

Reverse Polish notation or postfix notation :<br />

multiply<br />

A and B,<br />

divide C<br />

by D,<br />

add the<br />

results<br />

add B<br />

and C,<br />

multiply<br />

by A,<br />

divide<br />

by D<br />

divide C<br />

by D,<br />

add B,<br />

multiply<br />

by A<br />

A unary operator for which the Reverse Polish notation is the general<br />

convention is the factorial. In Reverse Polish notation the operators follow their<br />

operands; for instance, to add three and four, one would write "3 4 +" rather<br />

than "3 + 4". If there are multiple operations, the operator is given immediately<br />

after its second operand; so the expression written "3 − 4 + 5" in conventional<br />

infix notation would be written "3 4 − 5 +" in RPN: first subtract 4 from 3, then<br />

add 5 to that. An advantage of RPN is that it obviates the need for parentheses<br />

that are required by infix. While "3 − 4 * 5" can also be written "3 − (4 * 5)", that<br />

means something quite different from "(3 − 4) * 5". In postfix, the former would<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

Assist Prof., CSE, H.C.T.M (Kaithal) Page ‐ 171 ‐

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!