Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help creating expression tree

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help creating expression tree

    Hi

    I need a expression tree class that conver infix expressions to postfix and prefix, and i already have this classes:

    public class Stack<E>{
     
         private int d = -1;
         private int MAX = 100;
         private int size = 0;
         private E[] stack;
     
         @SuppressWarnings("unchecked")
         public Stack(int size){
              stack = (E[])new Object[size];
              this.size = size;
         }
     
         public Stack(){
              this(MAX);
         }
     
         public void push(E o) throws OverflowStackException{
              if (size == (d+1))
                   throw new OverflowStackException();
     
              d++;
              stack[d] = o;
         }
     
         public E top() throws EmptyException{
              if(d == -1)
                   throw new EmptyException();
              return stack[d];
         }
     
         public E pop() throws EmptyException{
              if(d == -1)
                   throw new EmptyException();
              d--;
              return stack[d+1];
         }
     
         public int size(){
              return d+1;
         }
     
         public boolean empty(){
              return d == -1;
         }
     
    }


    public class BTree<E>{
     
         E element;
         BTree<E> dir;
         BTree<E> esq;
     
         public BTree(){
              this(null);
         }
     
         public BTree(E x){
              element = x;
              esq = null;
              dir = null;
         }
     
         public BTree(E x, BTree<E> d,  BTree<E> e){
              element = x;
              dir = d;
              esq = e;
         }
     
         public E element() throws InvalidNode{
              if(this == null)
                   throw new InvalidNode("Null node");
              return element;
         }
     
         public void setElement(E x){
              element = x;
         }
     
         public void setDir(BTree<E> d){
              dir = d;
         }
     
         public void setEsq(BTree<E> e){
              esq = e;
         }
     
         public BTree<E> getDir(){
              return dir;
         }
     
         public BTree<E> getEsq(){
              return esq;
         }
     
    }

    and now i need that class desesperatly i didnīt get anything yet and iīm getting out of time, someone please help me??
    I need to use the String Tokenizer and is all i can use from java.util.


    Thanks in advance


  2. #2
    Junior Member
    Join Date
    Dec 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help creating expression tree

    Somebody can help me??

Similar Threads

  1. Creating an Expression Tree
    By vluong in forum Collections and Generics
    Replies: 0
    Last Post: November 28th, 2009, 10:41 PM
  2. B+ Tree
    By mikesir87 in forum Java Theory & Questions
    Replies: 0
    Last Post: November 20th, 2009, 09:52 AM
  3. Quick binary tree question.
    By Sinensis in forum Java Theory & Questions
    Replies: 1
    Last Post: November 15th, 2009, 08:28 PM
  4. B+ Tree implementation
    By programmer in forum Java Theory & Questions
    Replies: 2
    Last Post: November 15th, 2009, 04:47 PM
  5. Binary Search Tree
    By Koren3 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 12th, 2009, 08:27 AM