This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Binary Tree Search Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Binary Tree Search" Watch "Binary Tree Search" New topic

Binary Tree Search

Nessa Student

Joined: Jun 11, 2004
Posts: 1

I am in CIS 275 at Devry Univ. for my lab project I am supposed to create a method to search through a binary tree ( if node == quarry return node location, if less than node move left and compare again, if greater than node move right and try again, if not found return null) but I have no idea how to create that in code, can someone please help me? (this project is due Saturday at midnight)

thank you all!

Stefan Krompass
Ranch Hand

Joined: Apr 29, 2004
Posts: 75

the implementation of search in binary trees is as simple as the description you have. Assume you have a binary tree which stores ints in nodes:

Then you can implement a method search:

[ June 11, 2004: Message edited by: Stefan Krompass ]
I agree. Here's the link:
subject: Binary Tree Search
jQuery in Action, 3rd edition