[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reverse pop, return value
From: |
David Kastrup |
Subject: |
Re: Reverse pop, return value |
Date: |
Tue, 17 Nov 2009 17:53:42 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) |
LanX <lanx.perl@googlemail.com> writes:
> Hi
>
> I tried to realize a reverse pop which pops from the end of the list,
> but the code get's "lengthy"....
Don't do that. If you really need to process the list in reverse order,
_first_ reverse it, then process it from the front.
Reversing is O(n), popping from the front O(1), so working off the whole
list is O(n). Popping from the end is O(n), making work on the whole
list O(n^2).
--
David Kastrup
- Remove last element in a list, Nordlöw, 2009/11/17
- Re: Remove last element in a list, LanX, 2009/11/17
- Reverse pop, return value, LanX, 2009/11/17
- Re: Reverse pop, return value, Lennart Borgman, 2009/11/17
- Message not available
- Re: Reverse pop, return value, LanX, 2009/11/17
- Re: Reverse pop, return value, Barry Margolin, 2009/11/17
- Re: Reverse pop, return value, LanX, 2009/11/17
- Re: Reverse pop, return value, Barry Margolin, 2009/11/19
- Re: Reverse pop, return value,
David Kastrup <=
- Re: Reverse pop, return value, LanX, 2009/11/17
Re: Remove last element in a list, Barry Margolin, 2009/11/17