How to insert node to tree while comparing string instead of int
I want to create a program that insert phone record to a binary search tree...
The record accept name and phone number as input, so when i want to compare the data(key), which is the string type name, i have to compare it in alphabetical order.
For example when i insert Kevin to the tree, Aaron will be the first node, and Brandon will be inserted again to the tree, the program will compare these 2 strings and insert to the left node if the alphabet is less than the first node. Does anyone know how to compare them? I know the equal method check whether string name is same and compareTo is to compare both string but i dont really understand how it works, can anyone explain the method with examples?