Evaluate the following prefix expression " ++ 26 + - 1324"

Answer Posted / vivek

take a stack and push operators into stack such as (*,+,_,/,etc) and when 2 operands(let a & B) appears pop out 1 operator and perform the expression (a operator B) and push it in 2 a stack



eg: ++2 6+-13 2 4
+(2+6) +-13 2 4
+8+(13-2)4
+8+11 4
+8(11+4)
+8 15
8+15
23 ans

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define threaded binary tree. Explain its common uses

501


What is binary tree and its properties?

463


What is a data structure node class?

501


What are the advantages and disadvantages of linked list?

428


Explain the difference between a list and array.

546






Describe tree database. Explain its common uses.

555


How does hashset work internally in java?

517


What is the prerequisite for binary searching?

567


Suppose in an integer array, there is 1 to 100 number, out of one is duplicate, how to find?

540


What method is used to place a value onto the top of a stack?

571


Why hashmap is faster than hashtable?

513


What is the method to find the complexity of an algorithm?

545


Can you distinguish between ArrayList and Array?

587


What is 2 dimensional linked list?

592


Why is sorting and classifying important?

466