Add iterating over initial array in reverse order.#99
Add iterating over initial array in reverse order.#99askanium wants to merge 1 commit intobrennerm:masterfrom
Conversation
|
Iterating over an array without modifying it is elementary python. Try the benchmark : also note that |
|
Depends on the definition of efficiently. From a Time Complexity perspective, you are completely right, the solution I suggested is inferior. From a Space Complexity perspective, both existing solutions take Time Complexity is more important than Space Complexity in most of the cases, as space is cheap, but for some specific cases, knowing how to iterate without duplicating the array might save the day. Having said this, I don't mind if you close this PR if you think it doesn't bring value, just wanted to explain why I created it in the first place. |
|
There are many perspectives but, generally speaking, only one acceptable definition : Are you assuming that Reversed is a type in the Python implementation. And the function I think you can improve the example to show that both possibilities exists and that reversed performs faster (which is perfectly logical and without consuming any space) |
|
I don't see how the definition you posted contradicts my comment about it. Saying "this algorithm is efficient time-wise" and "this algorithm is efficient space-wise" is perfectly valid and describes more accurately what type of efficiency was achieved. Indeed, while |
|
what about mentioning this notes in the code ? That would be very instructive for newcomers, doesn't it ? |
No description provided.