Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help
The ASP Free website provides in-depth information on the latest developer tools available from Microsoft. Our cadre of writers, highly experienced industry experts, reveals the best ways to use established technologies as well as new and emerging technologies. Our coverage of Microsoft's development and administration technologies is among the most respected in the IT industry today.

ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Download and Activate to enter!

Intel® Graphics Performance Analyzers is a powerful tool suite for analyzing and optimizing your games, media, and graphics-intensive applications. Used by some of the best developers on the planet, Intel GPA lets you maximize your app’s performance.


Tutorials
| Forums

Download to Enter
| Contest Rules

DOWNLOAD INTEL® GPA FOR FREE

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 12th, 2006, 06:38 PM
spazzzer spazzzer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 10 spazzzer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 8 sec
Reputation Power: 0
Binary Search Tree Problem

How would I clone a Linked list que?

Reply With Quote
  #2  
Old March 12th, 2006, 07:15 PM
dechala dechala is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 87 dechala User rank is Private First Class (20 - 50 Reputation Level)dechala User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 2 h 17 m 7 sec
Reputation Power: 8
Quote:
Originally Posted by spazzzer
How would I write a recursive algorithm that returns the Binary Search Tree (BST) object containing the value argument and return null if the value cannot be found?

What I have so far is:

abstract class BST {
public int data;
public BST left;
public BST right;
static public BST find(BST root, int value);
}

then in another class where I define this method I have the method heading:

static public BST find(BST root, int value)
{


}

Does anyone know how to solve this problem?


DO YOUR OWN HOMEWORK!!!!!!!!!!!!!!!!!!!!!!

Reply With Quote
  #3  
Old March 12th, 2006, 07:51 PM
mvantuyl's Avatar
mvantuyl mvantuyl is offline
Walrus Gramps
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2005
Location: San Antonio, Texas
Posts: 1,229 mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)mvantuyl User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 48973 Folding Title: Beginner FolderFolding Points: 48973 Folding Title: Beginner FolderFolding Points: 48973 Folding Title: Beginner Folder
Time spent in forums: 3 Weeks 4 Days 5 h 55 m 23 sec
Reputation Power: 617
Send a message via ICQ to mvantuyl
Quote:
Originally Posted by spazzzer
Does anyone know how to solve this problem?
Yes.

You may want to take a look at this link. It will give you some assistance in restating your question in a way which will be more likely to elicit a more helpful response.
__________________
All science is either physics or stamp collecting. - Ernest Rutherford

How To Ask Questions The Smart Way by Eric S. Raymond

Last edited by mvantuyl : March 12th, 2006 at 07:58 PM.

Reply With Quote
  #4  
Old March 12th, 2006, 11:44 PM
spazzzer spazzzer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 10 spazzzer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 8 sec
Reputation Power: 0
It is not homework, It is an interest. Anyway, Could someone tell me if this is the right algorithm for a search in the Binary Search Tree algorithm?

abstract class BST {

public int data;
public BST left;
public BST right;
static public BST find(BST root, int value);

}


public class findBST extends BST {

static public BST find(BST root, int value)
{
if (root == null)
return null;

if (value < root)
return find(left, value);
else if (value > root)
return find(right, value);
else
return root;

}

}

Reply With Quote
  #5  
Old March 13th, 2006, 08:16 PM
spazzzer spazzzer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 10 spazzzer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 8 sec
Reputation Power: 0
anyone know?

Reply With Quote
  #6  
Old March 13th, 2006, 08:38 PM
tfecw tfecw is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Nov 2004
Location: Washington DC
Posts: 2,748 tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 3 Days 6 h 49 m 8 sec
Reputation Power: 1569
Send a message via AIM to tfecw
Binary Search Trees are a very very well known algorithm.

Here's one site i found mcgill University
Google returned back 17.3 million hits on Binary Search Tree.

Compare your algorithm with those and see what you come up with.

As a side note, i though this was pretty cool Graphical Binary Search Tree
__________________
Open for extension, closed for modification

Reply With Quote
  #7  
Old March 14th, 2006, 04:37 PM
spazzzer spazzzer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 10 spazzzer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 8 sec
Reputation Power: 0
I have spent atleast a couple hours looking for a search algorithm for the binary search tree. I cannot seem to find one, that is why I am asking here. I figure someone here must know, . Anyone help PLEASE?

Reply With Quote
  #8  
Old March 14th, 2006, 04:45 PM
tfecw tfecw is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Nov 2004
Location: Washington DC
Posts: 2,748 tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 3 Days 6 h 49 m 8 sec
Reputation Power: 1569
Send a message via AIM to tfecw
Why did you spend a couple of hours looking? The link i posted has the algorithem.

Reply With Quote
  #9  
Old March 14th, 2006, 06:33 PM
spazzzer spazzzer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 10 spazzzer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 8 sec
Reputation Power: 0
Quote:
Originally Posted by tfecw
Why did you spend a couple of hours looking? The link i posted has the algorithem.


I spent acouple of hours looking when I first needed the algorithm. But the link you posted has a algorithm and its not recursive. The search algorithm they use is:

TreeSearch (x, k)

while x != NIL and k != key[x]
if k < key[x]: x <- left[x]
if k > key[x]: x <- right[x]
return x

Would my algorithm return the same result? (I am not sure, =/)

Reply With Quote
  #10  
Old March 14th, 2006, 10:34 PM
tfecw tfecw is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Nov 2004
Location: Washington DC
Posts: 2,748 tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 3 Days 6 h 49 m 8 sec
Reputation Power: 1569
Send a message via AIM to tfecw
Have you tried your algorithm yet? If not, what's stopping you. It seems the easiest way to see if it works is to try it.

Reply With Quote
  #11  
Old March 14th, 2006, 10:53 PM
spazzzer spazzzer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 10 spazzzer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 8 sec
Reputation Power: 0
Well, that would mean making the entire Binary Search Tree algorithm, which is pretty big. The easiest way would be to find someone who knows this algorithm, and he could just read my 5 lines and tell me if it works or not . Does anyone know?

Reply With Quote
  #12  
Old March 15th, 2006, 09:34 AM
tfecw tfecw is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Nov 2004
Location: Washington DC
Posts: 2,748 tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 3 Days 6 h 49 m 8 sec
Reputation Power: 1569
Send a message via AIM to tfecw
Quote:
Well, that would mean making the entire Binary Search Tree algorithm, which is pretty big. The easiest way would be to find someone who knows this algorithm, and he could just read my 5 lines and tell me if it works or not . Does anyone know?


...

If you don't plan on implementing the rest of the tree, why are you trying to write the search?

Reply With Quote
  #13  
Old March 15th, 2006, 10:25 AM
spazzzer spazzzer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 10 spazzzer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 8 sec
Reputation Power: 0
Because I am using the search algorithm from the binary search tree, but it is more like a hybrid algorithm used for something else. Does anyone know if my 5 lines are correct or not? =/, I never though it would be this hard to find a simple answer. The reason I want to be so certain is because I dont want to have debugging issues down the road.

Reply With Quote
  #14  
Old March 15th, 2006, 12:33 PM
tfecw tfecw is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Nov 2004
Location: Washington DC
Posts: 2,748 tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level)tfecw User rank is General 9th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 3 Days 6 h 49 m 8 sec
Reputation Power: 1569
Send a message via AIM to tfecw
Quote:
Because I am using the search algorithm from the binary search tree, but it is more like a hybrid algorithm used for something else.


Then why not test it with your something else that you do plan on implementing

Quote:
The reason I want to be so certain is because I dont want to have debugging issues down the road.

Debugging is a part of programming. Writing your own test code goes a long way in terms of simplifying debugging. It's how i'd test your code. So i I'm a little curious why I, or someone else should i spend the time writing that code, to test your function? This is a very important skill that you might as well learn now, so you'll be equipped with the knowledge to test the next thing you write. You came up with your initial algorithm, so why not try coming up with something that tests it?

Last edited by tfecw : March 15th, 2006 at 12:36 PM. Reason: even i was embarrassed by the lack of spelling skills...

Reply With Quote
  #15  
Old March 15th, 2006, 08:01 PM
spazzzer spazzzer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 10 spazzzer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 8 sec
Reputation Power: 0
Quote:
Originally Posted by tfecw
Then why not test it with your something else that you do plan on implementing


Debugging is a part of programming. Writing your own test code goes a long way in terms of simplifying debugging. It's how i'd test your code. So i I'm a little curious why I, or someone else should i spend the time writing that code, to test your function? This is a very important skill that you might as well learn now, so you'll be equipped with the knowledge to test the next thing you write. You came up with your initial algorithm, so why not try coming up with something that tests it?


I have plenty experience in the debugging department, I just did not want a cascading debugging problem like I have said before. I have also said that it would be easier for someone who knows the algorithm to take alook at my 5 lines of code, and tell me if it would work with a standard binary search algorithm. So if anyone could do this for me, I would be very grateful. Obviously tfecw cannot answer my question. I am asking this question to someone who knows the binary search algorithm. Thanks.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Binary Search Tree Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap