What would be the Prefix notation for the given equation? [code]A^B^C^D[/code]

What would be the Prefix notation for the given equation?
Code:
A^B^C^D
A. ^^^ABCD
B. ^A^B^CD
C. ABCD^^^
D. AB^C^D
 
Answer: a
Explanation: Reverse the equation or scan the equation from right to left. Apply the infix-prefix algorithm. Here we have to remember that the exponentiation has order of associativity from right to left. Therefore the stack goes on pushing ^. Therefore resulting in ^^^ABCD.
 

Tìm kiếm

Back
Top