hello everyone, it's me again. i got another question for you. am now reading about stacks and i've come across this prb that i seem to have difficulty in. here we go use a stack in order to implement a translator from infix to postfix notation. (infix notation: we understand. 5+9 and 5/8 operators + and / r written between brackets) (postfix notation: computer understands 59 + 58/) a compiler evaluates arithmetic expressions in postfix notation. hence they translate tbhe infix notation to postfix notation. so for example, we write (5+9)/5+2*8 and the compiler translates it to 59+5/28*+ so this is it. am supposed to write a class that converts infix to postfix. infix is read as stringbuffer, java.util.stack is imported, watever my expressions are, they should include everything (+,-,/,*,%,^) but of course, according to priority. am sure u all know how it goes: ^,*,/,%,+,- i even wrote the "algorithm" for this but i keep on screwing things up. here it is *push '(' onto the stack *Append ')' to infix(append at the end) *For each character c in infix from left to right and while the stack isn't empty do if c is a digit then append it to postfix if c is '(' then push c onto the stack if c is an operator then while top of stack is an operator of equal or higher priority than c (Pop and append all of such expressions to postfix push c onto stack if c is ')' then while top of stack is not '(' Pop operator from stack and append it to postfix pop '(' from stack and discard it
i know, u guys will probably ban me now :d but pretty plz, i really need the help :( thank you
Has this book reading has become a cover up story for posting home work now?
Which books that doesn't teach how to solve these problems, but has these problems? I would like to know the detail of such book so that I wouldn't buy it even accidentally!!!
unfortunately, u'r half right first i dont have the money to enter college. this is why am trying to learn on my own. watever it is that i can grab from the book. second, it's called DATA STRUCTURES AND ALGORITHMS IN JAVA dude, if it were hw, i'd have said it. why waste my time and make up some story.