May be I didn't understood your logic.
According to original question for
I/P  ----kapilra
O/P --kaapilr..
Now,
-what if we create a binary tree with root as the first element of the
string and if the next character is equal then place it to left else place
it to right. Similar comparison will be done while inserting all the other
nodes too .

   At root you will insert k(count=1)
After that a

                     k(1)
                   /
                a(1)
Then you will insert p,
                     k(1)
                   /      \
                 a(1)    p(1)
 And so on.

>
>> after that if InOrder traversal is performed.. it would give us the
>> desired output.
>>
>
If by inoder traversal we can get desired output then please how me how
using a small example :).


>
>> Snehi
>>
>>
>> On Wed, Jun 22, 2011 at 9:48 PM, DK <[email protected]> wrote:
>>
>>> No. This is equivalent to a sort with comparisons based on index of first
>>> occurrence in the input string. Any comparative algorithm is O(n log n) and
>>> a non comparative algorithm can be O(n) only by using counting or radix
>>> sorting etc.
>>>
>>> --
>>> DK
>>>
>>> http://twitter.com/divyekapoor
>>> http://www.divye.in
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/algogeeks/-/GeqwF_snzQQJ.
>>> 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?hl=en.
>>>
>>>
>>  --
>> 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?hl=en.
>>
>
>  --
> 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?hl=en.
>

 --
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?hl=en.

-- 
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?hl=en.

Reply via email to