| Username |
Post |
| meamigo |
Posted
on 19-Nov-03 08:55 PM
1)Evaluate (find the numeric value of) the following RPN expression. ------------------ 7 4 + 9 3 - * ------------------ 5 3 - 1 6 2 * * 4 + 7 - * 2)Translate the following infix expression to RPN ------------------ (6 - 3) * (8 + 4) ------------------ 2 * (8 + 1) - 3 * 5 / 4 - 7 3)an expression tree can be used to represent arithmatic expressions. Operands are placed in leaf nodes, operators (+,-,*,/) in non-leaf nodes. Draw the expression trees associated with the following infix expressions. 4 + 5 (2 + 5) * (7 + 9) - 4
|
| meamigo |
Posted
on 19-Nov-03 09:02 PM
3)an expression tree can be used to represent arithmatic expressions. Operands are placed in leaf nodes, operators (+,-,*,/) in non-leaf nodes. Draw the expression trees associated with the following infix expressions. 4 + 5 (2 + 5) * (7 + 9) – 4 4) Assume ListNode and List are classes. Write a new member function ‘size’ which will returb the number of nodes in the linked list. The prototype is given below. Write the implementation. int size(ListNode *head) const ; //Prototype for function 5) List 5 primitive operations for the stack ADT.
|
| confused |
Posted
on 19-Nov-03 09:07 PM
this is faaar beyond my knowledge bro..i can help u with heheh basic input and output..lol..
|
| jaya_nepal |
Posted
on 19-Nov-03 10:19 PM
meamig bro.. whazz RPN.? Ill try do it.
|
| dananah |
Posted
on 19-Nov-03 11:04 PM
dunno much about C++...just a bit on java....and they are similar. anyways seems like ur questions about data structures.. 1)Evaluate (find the numeric value of) the following RPN expression. ------------------ 7 4 + 9 3 - * = (7 + 4) 9 3 - * = 11 9 3 - * = 11 (9 - 3) * =11 6 * = (11 * 6) = 66 (ans) ------------------ 5 3 - 1 6 2 * * 4 + 7 - * = (5-3) 1 6 2 * * 4 + 7 - * =2 1 6 2 * * 4 + 7 - * = 2 1 (6 * 2) * 4 + 7 - * = 2 1 12 * 4 + 7 - * = 2 (1 * 12) 4 + 7 - * = 2 12 4 + 7 - * = 2 (12 + 4) 7 - * =2 16 7 - * = 2 (16 - 7) * = 2 9 * =(2 * 9) = 18 (ans) 2)Translate the following infix expression to RPN ------------------ (6 - 3) * (8 + 4) hope this will explains it: first separate the expressions to the order its supposed to be calculated (divide and conquer rule) 6 3 - == the postfix expression for (6 - 3) 8 4 + == the postfix expression for (8 + 4) therefor = 6 3 - 8 4 + * (ans) ------------------ 2 * (8 + 1) - 3 * 5 / 4 - 7 seems like u might have missed some ()s in this expression 2 * (8 + 1) - 3 * 5 / 4 - 7 will give u... =2 * 9 - 15 / 4 - 7 =18 - 3.75 (character double??) - 7 = 7.25 (is this supposed to be the ans u get from calculating ur expression??) anways postfix expression would be: 2 8 1 + * == the postfix expression for 2 * (8 + 1) 3 5 * 4 / == the postfix expression for 3 * 5 / 4 2 8 1 + * 3 5 * 4 / - 7 - (ans) anyways will post the other ans to the other questions if i have time to draw it..(do it).. read and practice urself..understanding data structure is important... go and google..lots of good example and explanation in the web ;) cheers..:D (ps check the ans...dun have time and havent been doing this for a while...so might be wrong..:D..)
|
| dananah |
Posted
on 20-Nov-03 12:27 AM
heres the ans for question 3...try to understand it..:D. Question 4...its quite easy ;)...(i dunno how to code it in C++ so do it urself..;)..) and Question 5..READ any books on Object Oriented Programming!!! the ans is there..:D.. cheers :D
|
| meamigo |
Posted
on 20-Nov-03 06:55 AM
Thanks a lot ppl!!!!!!!!!!!!!!!!!!!!!!!!
|
| meamigo |
Posted
on 20-Nov-03 06:56 AM
thanks a lot ppl!!!!!!!!
|
| Recon |
Posted
on 20-Nov-03 08:06 AM
Its better to do C++ problem yourself..otherwise you wouldn't learn nothing....
|
| L-a-x |
Posted
on 20-Nov-03 06:42 PM
maan it's 4 + 5 *(2 + 5) * (7 + 9) - 4 = 5 *7 * 15
|
| dananah |
Posted
on 21-Nov-03 02:04 AM
meamigo bro...as recon suggested...better start doin it urself..:D.. (practice makes perfect..:D) programming is a killer...duno why im doing it..:| if u dun get it..its tough...really tough(im having lots of trouble with it) and data structures is a fundamental in programming..its starts to get fun when you understand..and your program works out....so start having fun... cheers..:D
|
| askme |
Posted
on 27-Nov-03 01:27 AM
Please look at the precedence of the arithmetic operators. Items in the bracket is calculated first, then multiplication and division, then only plus or minus. Overall expression is calculated from left to right(I am not sure check it) See http://www.cprogramming.com/
|