Welcome to Dream.In.Code
Become a Java Expert!

Join 149,477 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,769 people online right now. Registration is fast and FREE... Join Now!




Binary Tree

 
Reply to this topicStart new topic

Binary Tree

FuuFuu
18 Apr, 2007 - 06:06 AM
Post #1

New D.I.C Head
*

Joined: 16 Apr, 2007
Posts: 1



Thanked: 1 times
My Contributions
I need help on writing a driver for my class. i need a binary Tree that implements letters asked by the programmer and prints out in postorder form.
//TreeNode.java
CODE

public class TreeNode
{
    private Object value;
    private TreeNode left;
    private TreeNode right;
    
    public TreeNode(){}
    
    public TreeNode(Object initValue, TreeNode initLeft, TreeNode initRight)
    {
        value = initValue;
        left = initLeft;
        right = initRight;
    }
    
    public Object getValue()
    {
        return value;
    }
    
    public TreeNode getLeft()
    {
        return left;
    }
    
    public TreeNode getRight()
    {
        return right;
    }
    
    public void setLeft(TreeNode theNewLeft)
    {
        left = theNewLeft;
    }
    
    public void setRight(TreeNode theNewRight)
    {
        right = theNewRight;
    }
}

User is offlineProfile CardPM
+Quote Post

spullen
RE: Binary Tree
18 Apr, 2007 - 07:50 AM
Post #2

D.I.C Regular
Group Icon

Joined: 22 Mar, 2007
Posts: 330



Thanked: 1 times
Dream Kudos: 50
My Contributions
I would suggest taking a look at this http://en.wikipedia.org/wiki/Binary_search_tree
I know when I had to do an implementation of a binary tree there were a lot more classes. I think, at the least, you need to make a node class to store the data, the actual BinaryTree class and an iterator that will do the post order traversal of the tree.

This post has been edited by spullen: 18 Apr, 2007 - 07:50 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 03:11PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month