as> I'm pretty confident append itself (and a+[n]) are linear in
as> N=len(a) ...
Yes, as I indicated in an earlier reply. The overall construction of his
data structure would be O(N**2) or O(N*log N). The latter is for binary
tree construction, but I didn't know what the OP was going t
Alexander Schmolck <[EMAIL PROTECTED]> writes:
> [EMAIL PROTECTED] writes:
>
> > > "Bart" == Bart Van Loon <[EMAIL PROTECTED]> writes:
> >
> > >> Such an operation will be O(N**2),
> >
> > Bart> why is that?
> >
> > The a[:] operation makes a copy of a (as will the x = a + [n] idi
[EMAIL PROTECTED] writes:
> > "Bart" == Bart Van Loon <[EMAIL PROTECTED]> writes:
>
> >> Such an operation will be O(N**2),
>
> Bart> why is that?
>
> The a[:] operation makes a copy of a (as will the x = a + [n] idiom).
I'm pretty confident append itself (and a+[n]) are linear in
> "BJörn" == BJörn Lindqvist <[EMAIL PROTECTED]> writes:
BJörn> On 2/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>>
Bart> #--
Bart> def addnumber(alist, num):
Bart> """ work around the inplace-ness of .append """
B
On 2/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Bart> #--
> Bart> def addnumber(alist, num):
> Bart> """ work around the inplace-ness of .append """
> Bart> mylist = alist[:]
> Bart> mylist.append(num)
>
> "Bart" == Bart Van Loon <[EMAIL PROTECTED]> writes:
>> Such an operation will be O(N**2),
Bart> why is that?
The a[:] operation makes a copy of a (as will the x = a + [n] idiom).
Bart> I am building a binary tree where each node is a list. the two
Bart> children are the p
It was Mon, 5 Feb 2007 05:01:28 -0600, when [EMAIL PROTECTED] wrote:
>
> Bart> #--
> Bart> def addnumber(alist, num):
> Bart> """ work around the inplace-ness of .append """
> Bart> mylist = alist[:]
> Bart> mylist.app
It was Mon, 05 Feb 2007 11:00:50 GMT, when Kent Johnson wrote:
> Bart Van Loon wrote:
>> Hi all,
>>
>> I would like to find out of a good way to append an element to a list
>> without chaing that list in place, like the builtin list.append() does.
>>
>> currently, I am using the following (for a
Bart Van Loon wrote:
> Hi all,
>
...
>
> #--
> def addnumber(alist, num):
> """ work around the inplace-ness of .append """
> mylist = alist[:]
> mylist.append(num)
> return mylist
> #
Bart Van Loon wrote:
> Hi all,
>
> I would like to find out of a good way to append an element to a list
> without chaing that list in place, like the builtin list.append() does.
>
> currently, I am using the following (for a list of integers, but it
> could be anything, really)
>
> #---
Bart> #--
Bart> def addnumber(alist, num):
Bart> """ work around the inplace-ness of .append """
Bart> mylist = alist[:]
Bart> mylist.append(num)
Bart> return mylist
Bart> #
11 matches
Mail list logo