Hi..

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

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

Thanks.

Recommended Answers

All 3 Replies

Any idea?

Yes. Use e.g

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

I used a BST like this as part of an english-to-french translator.

Yes. Use e.g

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

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.