@Anil: Dictionary is given to you. For each string t in array
u = sort(t).
if(s == u)
print (t).
If dictionary has millions of words. So you will go for
each word one by one. Then How will make it efficient in terms of
time.
-Nagendra
On Sun, Aug 30, 2009 at 3:56 PM, Anil C R<[email protected]> wrote:
>
> are we like given a dictionary or something?
> if we are, its quite simple...
> 1. load the dictionary into an array.
> 2. sort the given string lexicographically. call it s
> 3.t for each string t in the array,
> u = sort
> if s=u then print t
>
> then again, if we are asked to print all permutations, we can do it
> recursively...or there is Johnson-Trotter:
> http://en.wikipedia.org/wiki/Steinhaus%E2%80%93Johnson%E2%80%93Trotter_algorithm
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---