Just of the top of my head.
You're dealing with *2* strings here.
So the *naive* method you quoted wont be that
bad.
Use a sort. The basic operation here being
string compare, which takes up O(n) time
NOTE 'n' is the length of the strings.
So, using a sort the complexity really is
O(2n log 2), Isn't it?
Which is O(n) really, n being length of the strings.
NO extra space either.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to