• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Expression Tree build() problem

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to build an infix expression tree from a tokenized string: "( ( ( 2 + 6 ) * 3 ) + ( 7 - 3))"

My build method is as follows, so far:

Private TreeNd build()
{
String s = tokenizer.nextToken();
TreeNd r = new TreeNd();
r.setLeft(build());
r.setElement(s);
r.setRight(build());
s = tokenizer.nextToken();

return r;
}

I am wracking my brain trying to figure out why this doesn't work,....any hints please?

Thanks a ton!
 
Nina Moore
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops, should have mentioned that the string my (non-working) build method gets sent doesn't have any )'s or ('s in it.

But it still doesn't work.

thanks again
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic