On 2007-02-04, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
How about the traditional programming languages like C, Pascal
or C++?
For a start they don't have a built in list type. C and Pascal
don't even have one in the standard library. C++ has STL
vectors and if you, the
En Sat, 03 Feb 2007 21:34:19 -0300, Dongsheng Ruan [EMAIL PROTECTED]
escribió:
This seems to be clever to use reference for list.
Is it unique to Python?
How about the traditional programming languages like C, Pascal or C++?
Python is written in C - so obviously it can be done in plain
In [EMAIL PROTECTED], Dongsheng Ruan wrote:
This seems to be clever to use reference for list.
Is it unique to Python?
No of course not. Java is very similar in only passing references around
for objects. And `ArrayList` and `Vector` behave similar to Python lists.
How about the
My confusion comes from the following piece of code:
memo = {1:1, 2:1}
def fib_memo(n):
global memo
if not n in memo:
memo[n] = fib_memo(n-1) + fib_memo(n-2)
return memo[n]
I used to think that the time complexity for this code is O(n) due to its
use of memoization.
However, I was told
Ruan schreef:
My confusion comes from the following piece of code:
memo = {1:1, 2:1}
def fib_memo(n):
global memo
if not n in memo:
memo[n] = fib_memo(n-1) + fib_memo(n-2)
return memo[n]
I used to think that the time complexity for this code is O(n) due to its
use of memoization.
Then how about Python's list?
What is done exactly when list.append is executed?
For list, is there another larger list initialized and the contents from the
old list is copied to it together with the new appended list?
Roel Schroeven [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
On Feb 4, 7:41 am, Ruan [EMAIL PROTECTED] wrote:
Then how about Python's list?
What is done exactly when list.append is executed?
For list, is there another larger list initialized and the contents from the
old list is copied to it together with the new appended list?
Qi ren you tian :-)
Ruan schreef:
Roel Schroeven [EMAIL PROTECTED] wrote:
Ruan schreef:
My confusion comes from the following piece of code:
memo = {1:1, 2:1}
def fib_memo(n):
global memo
if not n in memo:
memo[n] = fib_memo(n-1) + fib_memo(n-2)
return memo[n]
I used to think that the time complexity for
You mentioned it doubles in size.
Are you saying that a new double sized array is allocated and the contents
of the old list is copied there?
Then the old list is freed from memory?
It seems to be what is called amortized constant.
Say the list size is 100, before it is fully used, the append
Dongsheng Ruan schreef:
Roel Schroeven [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Ruan schreef:
Then how about Python's list?
What is done exactly when list.append is executed?
For list, is there another larger list initialized and the contents from
the old list is copied
This seems to be clever to use reference for list.
Is it unique to Python?
How about the traditional programming languages like C, Pascal or C++?
Roel Schroeven [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Dongsheng Ruan schreef:
Roel Schroeven [EMAIL PROTECTED] wrote in
11 matches
Mail list logo