Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Five Ways to Reverse a String of Words (C#, Perl 5, Perl6, Ruby, Haskell)

by akho (Hermit)
on Aug 12, 2007 at 15:41 UTC ( #632072=note: print w/ replies, xml ) Need Help??


in reply to Re: Five Ways to Reverse a String of Words (C#, Perl 5, Perl6, Ruby, Haskell)
in thread Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)

One may do this with a logarithmic number of concatenations, though (instead of linear). I don't see a feasible way to do such a thing with StringBuilder,

That may make concatenation faster than StringBuilder even in the case of a large number of strings.

I wonder how Perl's join actually works.


Comment on Re^2: Five Ways to Reverse a String of Words (C#, Perl 5, Perl6, Ruby, Haskell)
Select or Download Code
Re^3: Five Ways to Reverse a String of Words (C#, Perl 5, Perl6, Ruby, Haskell)
by fergal (Chaplain) on Aug 13, 2007 at 12:22 UTC

    How do you concatenate n strings in O(log n)? Every string will have to be concatenated to something least once, so it's not obvious to me how it could ever be less than O(n).

    Concatenating in pairs and then concatenating the results etc adds up to O(n).

      Oh.

      Now I'm ashamed of myself.

        Isn't that O(h)?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://632072]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (16)
As of 2014-10-21 17:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (106 votes), past polls