How to use Binary Search Tree with String? Is there any ready code?

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2008
Posts: 130
Reputation: Q8iEnG is an unknown quantity at this point 
Solved Threads: 2
Q8iEnG Q8iEnG is offline Offline
Junior Poster

How to use Binary Search Tree with String? Is there any ready code?

 
0
  #1
Nov 2nd, 2009
Hi..

Is there any ready-made code for "Binary Search Tree" for Strings?

if not, how to use Binary Search Tree with Strings?

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 130
Reputation: Q8iEnG is an unknown quantity at this point 
Solved Threads: 2
Q8iEnG Q8iEnG is offline Offline
Junior Poster
 
0
  #2
Nov 3rd, 2009
Any idea?
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,267
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 544
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator
 
-7
  #3
Nov 3rd, 2009
Yes. Use e.g

  1. if (stringname.compareTo(otherstringname) < 0)
  2. {
  3. // the word is "greater" than the other one, so e.g add it to its "right"
  4. }

I used a BST like this as part of an english-to-french translator.
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 130
Reputation: Q8iEnG is an unknown quantity at this point 
Solved Threads: 2
Q8iEnG Q8iEnG is offline Offline
Junior Poster
 
0
  #4
Nov 3rd, 2009
Originally Posted by jbennet View Post
Yes. Use e.g

  1. if (stringname.compareTo(otherstringname) < 0)
  2. {
  3. // the word is "greater" than the other one, so e.g add it to its "right"
  4. }

I used a BST like this as part of an english-to-french translator.
Umm, thanks for the code and reply mate.

But, I really didn't got it! and Will this will work with array of strings?

For example if I have an array of strings, will this method sort the array to a BST?
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC