This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Binary Search Method

 
Remaan Rem
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am trying to write a method: which does the following :
1. traverse the BST looking for a certain element of type T .
2. if found its value get changed with another one.
3. if not, even after completing all the traversal, we add the element to the place we stopped in :
So this is the code I have :


The basic question : is that am not very sure about the recursive call that comes under the second and the third if statments.

Does it really add the element in the specified location.

??
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remaan Rem wrote:...am not very sure about the recursive call that comes under the second and the third if statments.

Does it really add the element in the specified location.

??

Can you think of a way to test this?
 
Remaan Rem
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


maybe call it from another class, ir the same class.
and adding print statement? inside of the method
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic