It’s Time Again
Consider the time-complexity (i.e., running time) of various operations in CPython, the interpreter installed in CS50 IDE, focusing exclusively on each operation’s Average Case.
Answer the below in
(2 points.) Recall that a
dictis essentially a hash table, most of whose operations are in O(1). And yet Copy is in O(n). Why?
(2 points.) Recall that
strlenis in O(n) for strings in C. Though not documented, it turns out that
lenis in O(1) for strings in Python. How could that be?
Which resources, if any, did you find helpful in answering this problem’s questions?
About how long did you spend on this problem’s questions?