Java course evaluation assignment about binary search trees, emergency help!!!
I have a course evaluation assignment about binary search trees and idk how to do it?
That assignment is a combination of red-black trees and binary search trees in general and is until sunday at midnight,if anyone can help me somehow with the implementation and test or give me some hints how to do something, at least some simple program.
Here it is what it says:
Your solution of this assignment must be handed in before Sunday 23-Oct-
2011 at 23:59. It will be a part of the evaluation of the course. If you fail
this assignment you will fail the course.
The assignment is individual. Similar solutions from different persons will not
be accepted.
In this assignment you have to design and implement a “Hit Balanced Tree”
(HBT). 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.
pls i need some help, i would be really gratefull :D :D if it's possible something simple without generics and exceptions, HEEEEELP, at least some hints for something easy!!!!
Re: Java course evaluation assignment about binary search trees, emergency help!!!
Don't double post: http://www.java-forums.org/forum-lob...rch-trees.html
And ask a specific question rather posting an assignment . Recommended reading: How To Ask Questions The Smart Way
Re: Java course evaluation assignment about binary search trees, emergency help!!!
Quote:
Originally Posted by
doWhile
thanks, but i don't have some specific question, i just simply need help with the assignment :D :D :D
Re: Java course evaluation assignment about binary search trees, emergency help!!!
Quote:
Originally Posted by
doWhile
i don't have some specific question, i just need a bit of help about everything that's why i have post the whole assignment
Re: Java course evaluation assignment about binary search trees, emergency help!!!
Don't use the word emergency, urgent, etc. It will make you lose help. A huge wall of text is also going to limit responses.
Re: Java course evaluation assignment about binary search trees, emergency help!!!
Quote:
Originally Posted by
Alex_25
When an HBT is balanced, all the descendants of a node have lower hit count
than the node itself. On the other hteand, 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.
That paragraph says it all: for a parent node P and children L and R, the hit countt of P is higher than the counts of L and R. If the hit count of, say, L increases and becomes larger than P's hit count you have to rotate the tree, i.e. the original tree (P (L R)) becomes (L (- (P (- R)))) and you recursively apply the rotation to the new root node L. The same applies for node R. (- indicates a null sub tree)
kind regards,
Jos
Re: Java course evaluation assignment about binary search trees, emergency help!!!
basically, just write a compareTo method for the tree's elements and, everytime something is hit on the tree, call Collections.sort on it. I think that a TreeSet's
elements are only compared to each other when the structure of the set is modified. That is why i suggest manually calling the sort method whenever an element's
state changes in a way that invalidates the order of the tree.