Program to insert item in tree, JAVA Programming

public class TreeTest
{
    public static void main(String args[])
    {
        Tree t = new Tree();
        System.out.println("Populating");
        t.insertItem(1);
        t.insertItem(2);
        t.insertItem(3);
        t.insertItem(4);
        t.insertItem(5);
        t.insertItem(6);

        printBreak(t);
        System.out.println("Balancing");
        t.balance();
        printBreak(t);
        System.out.println("Deleting 3");
        t.deleteItem(3);

        printBreak(t);
        System.out.println("Balancing");
        t.balance();
        printBreak(t);
        System.out.println("Populating");
        t.insertItem(12);
        t.insertItem(9);
        t.insertItem(13);
        t.insertItem(10);
        t.insertItem(11);
        t.insertItem(9);

        printBreak(t);
        System.out.println("Balancing");
        t.balance();
        printBreak(t);
        System.out.println("Deleting 11, 2, 10");
        t.deleteItem(11);
        t.deleteItem(2);
        t.deleteItem(10);
        printBreak(t);
        System.out.println("Balancing");
        t.balance();

        printBreak(t);
        
        System.out.print("Getting 13's node: ");
        TreeNode node = t.search(13);
        System.out.println(node.getData());

        System.out.printf("Tree currently has %d nodes\n", t.count());

        System.out.print("Looking for 10: ");
        if(t.findItem(10))
        {
            System.out.println("Found");
        }
        else
        {
            System.out.println("Not Found");
        }

        System.out.print("Looking for 9: ");
        if(t.findItem(9))
        {
            System.out.println("Found");
        }
        else
        {
            System.out.println("Not Found");
        }

        System.out.print("In Order: ");
        t.printInOrder();
        System.out.print("Pre Order: ");
        t.printPreOrder();
        System.out.print("Post Order: ");
        t.printPostOrder();
    }

    public static void printBreak(Tree t)
    {
        t.printTree();
        System.out.println("--------------------------------");
    }
}

Posted Date: 2/18/2013 4:24:40 AM | Location : United States







Related Discussions:- Program to insert item in tree, Assignment Help, Ask Question on Program to insert item in tree, Get Answer, Expert's Help, Program to insert item in tree Discussions

Write discussion on Program to insert item in tree
Your posts are moderated
Related Questions
Question A What are the difference between an interface and an abstract class? Question B Describe Exception Handling in JAVA Question C Describe the following with resp


Explain Data Updates issues in data management? DATA UPDATES: Old titles must be removed regularly Data changes every time Prices change Transportation / shipping cost change

I have to Create a program that determine the shipping cost for an order based on he following chart: From To Price $0.00 $19.99 $2.95 $20.00 $49.99 $3.95

Farm Production System Project Description: I require software that will allow me to input/record the daily production of our farm and allow me to view the data back in the o

How to Drawing Images at Actual Size Once the image is loaded draw it in the paint() method by using the drawImage() method like this g.drawImage(img, x, y, io) img is a

cocos2d-x puzzle game for kids Project Description: I am seeking a skilled, reliable, and not very expensive cocos2d-x developer (with experience with iOS, Android, and prefe

Write a program of else statement in java? The else statement in Java // This is the Hello program in Java class Hello { public static void main (String args[]) { if (

Assignment Help >> JAVA Programming Learning Outcomes: 1. Use different program control statements in a programming language 2. Demonstrate the use of arrays with a programming

By pressing ‘6’ (i.e. key’6’ one time) on the keypad, the mobile shows ‘m’ on display screen in write text message area