|
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 :
public void setseqNo(int SeqNo)
{
seqNo = SeqNo;
}
public int getseqNo()
{
return seqNo;
}
The insert method in the BST class is the following:
protected Node <E> insert (Node root,Node newNode)
{
if (root == null)
root = newNode;
else
{
if((newNode.obj.getseqNo())<(root.obj.getseqNo()))
root.left = insert(root.left,newNode);
else
root.right = insert(root.right, newNode);
}
return root;
}
public void insertBST (E newObj)
{
Node temp = new Node (newObj);
root = insert (root,temp);
}
|
|
|
|