Newbie: conventional instead of recursive way
Brian Quinlan
brian at sweetapp.com
Fri Dec 20 14:25:34 EST 2002
Igor Zivkovic wrote:
> Thanks for the hints. I didn't reverse the whole list as you suggested
but
> used reversed list indexing to push the elements in the list in proper
> order.
Insertion and deletion, at the beginning of lists, are O(n) operations
(where n is the number of direct elements in the list).
So my algorithm will execute in O(m) (where m is the total number of
elements in the list and all sublists) while your solution will execute
in O(n*m).
It probably doesn't matter for your exercise but it might in real life.
Cheers,
Brian
More information about the Python-list
mailing list