I know how to insert integers into binary search tree

- Smaller to the left
- Larger to the right

But that formula would be applicable only if Data/Key is integer.

So i want to know how do i insert strings into BST

**I have searched the google but couldn't find any answer**

# Best How To :

Visit: http://www.kerryr.net/pioneers/ascii2.htm

Analyze the decimal equivalent of the alphabets.

For example: if you want to compare "leopard" and "cobra". Take first characters of both which are 'l' and 'c', convert them into their decimal equivalent which should be 108 and 99 respectively. Compare them if 1st is greater than 2nd then 2nd is smaller and if 2nd is greater than 1st. 1st is smaller. If both are equal, iterate to the next letter of both for example: to compare "fox" and "frog", we cannot find the smaller word by comparing only first character, we need to iterate to the 2nd character which is 'o' and 'r' respectively. Since 'o' is smaller than 'r'. So, "fox" is smaller than "frog". So compare cobra with leopard only till length 5 (length of word with less total number of characters). if both words are equal till length of word with less total number of characters then the word with greater length will be automatically greater. For example: "character" and "characteristic". Both are equal till length 9 but length of 2nd word is greater. So, 2nd will be greater.

Now, you can see "cobra" is smaller than "leopard". You can also assign values for alphabets by yourself. e.g.

a=1

b=2

c=3

d=4

.

.

.

z=26