• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Generic Binary Search Tree  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Edit: Ignore that. I was looking at the wrong method.

It would help if you told us what the exact compiler error message was.
 
Yanika Abela
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thanks for seeing my question

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

thanks!
 
Marshal
Posts: 64493
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 64493
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 64493
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yanika, please BeForthrightWhenCrossPostingToOtherSites
http://www.java-forums.org/advanced-java/67223-generic-binary-search-tree-help.html
 
Yanika Abela
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Get me the mayor's office! I need to tell her about this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!