none
Java course evaluation assignment about binary search trees, help!!! RRS feed

  • Question

  • hi i have a java evaluation course until java that is about binary serch trees....here is some of the words in the assignment... it's not the whole code i found...can somebody help me with the assignment???...it's until sunday midnight



    HBT is a new data structure invented for this assignment and it might 

    not be of any use in real programs.

    An HBT is an ordinary binary search tree where all the nodes contain an 

    extra attribute – number of hits. When a node is created the hit count is set 

    to zero. Every time the node is found with the find(), contains() etc. 

    methods its hit count is incremented by one.

    When an HBT is balanced, all the descendants of a node have lower hit count 

    than the node itself. On the other hand, it is still a search tree, where all 

    nodes in the left subtree of node have elements smaller than the element of 

    the node, and corresponding greater than for the right subtree.

    In other words: the root will be the node with the highest hit count. To the 

    left are the smaller elements and the larger element are to the right. This 

    rule is applied recursively down both the subtrees.

    Implement an HBT and make a proper test of your implementation.





    here is some of the code i try to modify 







    public class BinaryNode

    {

    protected Object element;

    protected Object left;

    protected int BinaryNode;

    protected Object right;



    /**

    * Creates a new tree node with the specified data.

    *

    * @param obj the element that will become a part of the new tree node

    */



    public BinaryNode(Object obj)

    {

    this.element = obj;

    this.left = null;

    this.right = null;

    }

    public BinaryNode (Object obj, int min, int max) 

    {

    this.element = obj;

    this.left = min;

    this.right = max;

    }
    Thursday, October 20, 2011 4:24 PM

Answers