Right to Left direction of scanning is suitable for evaluation of prefix expression - Data Structure

Q.  Which direction of scanning is suitable for the evaluation of a prefix expression?
- Published on 27 Aug 15

a. Left to Left
b. Right to Right
c. Left to Right
d. Right to Left

ANSWER: Right to Left
 

    Discussion

  • Nirja Shah   -Posted on 18 Nov 15
    For conversion of infix to prefix, right to left scanning is suitable.
    Example:
    + A ∗ B – C D ------- Apply ‘– ‘ to C and D
    + A ∗ B [ C – D ] -------- Apply ‘ ∗ ‘ to B and [ C– D ]
    + A [ B ∗ C – D ] -------- Apply ‘ + ‘ to A and [ B ∗ C – D ]
    A + B ∗ C – D

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)