Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Answer Posted / navneet kang

++26 + -1324
METHOD:-
Start scanning the string from the right one character at a time.
If it is an operand, push it in stack.
If it is an operator, pop opnd1, opnd2 and perform the operation, specified by the operator. Push the result in the stack.
Repeat these steps until arr of input prefix strings ends.
Solution
1)Push 4,2,13 in stack one by one
2) - operator encountered
3)Take out 13 and 2 from stack and perform operation
4)Now Stack consist of 4,11
5)+ operator encountered
6)Now Stack consist of 15
7)Now push 6 in stack,Hence Now Stack consist of 15,6,2
8)Perform add operation + encountered
9)Now Stack consist of 15,8
10)+ operator encountered
11)Now Stack consist of 23

Hence Answer is 23

Is This Answer Correct ?    7 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between hashset and linkedhashset?

1032


How to reverse singly link list?

879


Advanced problems related to Data Structures were asked

873


Tell me is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

876


Is complete binary tree?

812


Is it possible to make an array volatile in java?

849


What do u mean by array?

873


Is an arraylist an object?

905


How can someone display singly linked list from first to last?

803


What is the difference between array sort () and array sort t >()?

791


What do you mean by 2-3 tree?

869


What is the complexity of sorting algorithm?

839


What is the time complexity of selection sort?

791


Why sorting is used?

875


What is difference between rb tree and avl tree?

834