aspose file tools*
The moose likes Java in General and the fly likes Generic Binary Search Tree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Generic Binary Search Tree" Watch "Generic Binary Search Tree" New topic
Author

Generic Binary Search Tree

Yanika Abela
Greenhorn

Joined: Jan 02, 2013
Posts: 6
Hi all !! Happy New Year!!

I am currently working on a Generic Binary Search Tree. The insertion is done according to a variable - int seqNo and the get and set methods for seqNo are in a class called AnyClass (which is in a package named dataobjects).
Now, when I am calling the getseqNo() method in the BST class, it seems that it cannot be found.
I also have a class named Node that creates the nodes for the BST.

What is wrong with my code??

get & set Methods for seqNo is :



The insert method in the BST class is the following:



Thanks in advance!!
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3578
    
  15
Edit: Ignore that. I was looking at the wrong method.

It would help if you told us what the exact compiler error message was.


Joanne
Yanika Abela
Greenhorn

Joined: Jan 02, 2013
Posts: 6
hey thanks for seeing my question

The compiler error is : cannot find symbol - method getseqNo()

thanks!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38902
    
  23
Welcome to the Ranch
Are you sure you have spelt your error correctly? Even the tiniest spelling error will cause confusion; I cannot see what the error is. Which class is that method in.
You should use copy‑and‑paste to quote code, error messages, etc, otherwise we can suffer severe confusion.
Yanika Abela
Greenhorn

Joined: Jan 02, 2013
Posts: 6
unfortunately no, there is no spelling mistakes
Both the get and set methods for the seqNo are in a class named AnyClass. This used to work fine when I did a normal BST, but now I tried to convert it to a generic one and it is failing to work.
I could post the whole class if you need to and sorry about the code but it s my first time here.
Thanks!

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38902
    
  23
It might help if you posted the whole code. I cannot see the error.
Try rewriting the get method first, being sure which keyboard layout you are using. Similarly the place where the method call occurs. If you have a Ν which is Greek, but looks like an N, instead of the N somewhere, that could cause such an obscure error.
Yanika Abela
Greenhorn

Joined: Jan 02, 2013
Posts: 6
This is the AnyClass Class



The following is the Node Class



And finally the BST Class:



Thanks all! I really appreciate it as this is my first time in generics.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38902
    
  23
My! That’s awkward code to compile. I had to put the source files in the destination folder before I could get BST to compile.
You should have said there were 4 compiler errors. You are calling getSeqNo and getseqNo in different places; it ought really to be getSeqNo. You are also calling them on the values (obj), which are instances of E, whereas the getSeqNo method is in the AnyClass class.

But why are you giving a tree node a sequence number in the first place? That is not a usual feature of trees.
Yanika Abela
Greenhorn

Joined: Jan 02, 2013
Posts: 6
So, the seqNo can be simply seen as the node value. I changed getSeqNo to getseqNo but the compiler i still returning the same error!
Thanks!
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4547
    
    5

Yanika, please BeForthrightWhenCrossPostingToOtherSites
http://www.java-forums.org/advanced-java/67223-generic-binary-search-tree-help.html


luck, db
There are no new questions, but there may be new answers.
Yanika Abela
Greenhorn

Joined: Jan 02, 2013
Posts: 6
I'm sorry about that ... it's my first time here.. yes, i posted it on this other site http://www.java-forums.org/advanced-java/67223-generic-binary-search-tree-help.html because today I have spent 5 whole hours trying to solve this and I need as much help as possible. Sorry if I broke any rule or something and thanks for letting me know.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Generic Binary Search Tree