Timeline for Reversing string in PHP
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 12 at 0:49 | comment | added | J_H |
@GregBurghardt, the performance graph depicts quadratic performance, taking several seconds for a task that should complete within 20 msec. I just took verbatim the loop that appeared in another answer (since changed), with that innocuous looking "{$character}{$reversed}" expression being the core difficulty. Producing a reversed string of length 400 K, one character at a time, took ummm rather longer than expected. Nope, it's not exponential. It's the classic Shlemiel the painter’s algorithm, cf java's StringBuilder.
|
|
Jul 12 at 0:43 | comment | added | Greg Burghardt |
I'm a little confused about the last paragraph and performance graph. The performance graph looks exponential to me. It just doesn't look like you've hit the sharp rise upwards. Unless the graph isn't depicting .= performance?
|
|
Jul 11 at 0:44 | history | edited | J_H | CC BY-SA 4.0 |
amortized FTW
|
Jul 11 at 0:34 | history | edited | J_H | CC BY-SA 4.0 |
deleted 3 characters in body
|
Jul 11 at 0:27 | history | edited | J_H | CC BY-SA 4.0 |
added 73 characters in body
|
Jul 11 at 0:19 | history | edited | J_H | CC BY-SA 4.0 |
deleted 1 character in body
|
Jul 11 at 0:07 | history | edited | J_H | CC BY-SA 4.0 |
Add a quadratic complexity observation.
|
Jul 10 at 17:18 | history | answered | J_H | CC BY-SA 4.0 |