There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:hi Alicia,
have you tested your code?
I just put the lot in NetBeans, and it gives me the following errors:
1) SearchTree is not abstract, yet it does not implement the method 'V get(K key)' from
the interface 'Dictionary'.
And indeed, I cannot find it, but then again, I may have made some copy error
2) it complains that the following method
does not return anything
And talking about the method remove(). Campbell already mentioned it.
Suppose you want to remove a Node, that has Nodes to its left and right.
Now, removing that Node would leave these 'children' parentless. So you
must come up with something that repairs this situation.
For instance, if you are to remove the root, then you end up with a loose
left subtree and a loose right subrtree. So, one of the 'roots' of these subtrees
must become the new 'head' root.
Well, that's what I saw so far. Interesting assignment, but not so easy.
Greetz,
Piet
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:hi Alicia,
as Dutchman, I can't fault your English![]()
I'll try to find out what is happening in all the code (it's quite some code!),
but my first idea is that it would be very handy to include a method
and
That would make it much easier to remove a node, since you get easy
access to the node-to-be-removed, and the parent of that node,
so you can then relatively easy adjust the necessary pointers.
That will make the code in 'remove' much more readable.
Again, you may have implemented this already, I'll check (although that
maybe tomorrow, it's getting late here). And maybe someone else will step in.
Greetz,
Piet
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:well, starting with a fresh mind.... see how long that lasts.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
There are three kinds of actuaries: those who can count, and those who can't.
Winston Gutkowski wrote:
@Alicia: And I'm going to add a third point of view. Unfortunately, it may not be one you want to hear.
You have (almost certainly) written far too much code without testing properly.
(.....)
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Piet Souris wrote:(....)
As you see, I don't care what subtrees I have, as long as the infix printorder is okay.
(...)
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
There are three kinds of actuaries: those who can count, and those who can't.
Alicia Perry wrote:I found the error and now it works as it should.
I was stupid and I'm sorry I wasted your time.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Campbell Ritchie wrote:You can never test code and prove it works.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
No more fooling around. Read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|