in reply to Spliting array into nested sequential arrays
In the first case, the code is naive in many a few ways, not the least of which, it gets the output wrong -- not including the final sequence of the input. In the second case, it could all be combined into a single pass as below, but it is correct to call the complexity O(n), it will scale linearly with the number of elements.
Update: I see you fixed the desired output, but the code still gets it wrong.
Update2: My comment here about complexity ignores sort, as requested in the question.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Spliting array into nested sequential arrays
by GrandFather (Saint) on Oct 29, 2014 at 01:42 UTC | |
|
Re^2: Spliting array into nested sequential arrays
by Hameed (Acolyte) on Oct 29, 2014 at 01:44 UTC |