In python/algorithms, what is the time complexity of index lookup/assignment for lists (e.g. you have l = [1,2,3,4,5], what is big-O of doing: l[2] = 0)?
Answer
O(1)
^^ the reason it is O(1), is because doing delete via pop(i) is O(n) as a python tradeoff to make index assignment faster.
Question
In python/algorithms, what is the time complexity of index lookup/assignment for lists (e.g. you have l = [1,2,3,4,5], what is big-O of doing: l[2] = 0)?
Answer
?
Question
In python/algorithms, what is the time complexity of index lookup/assignment for lists (e.g. you have l = [1,2,3,4,5], what is big-O of doing: l[2] = 0)?
Answer
O(1)
^^ the reason it is O(1), is because doing delete via pop(i) is O(n) as a python tradeoff to make index assignment faster.
If you want to change selection, open document below and click on "Move attachment"
pdf
owner: kkhosravi - (no access) - ProblemSolvingwithAlgorithmsandDataStructures.pdf, p59
Summary
status
not learned
measured difficulty
37% [default]
last interval [days]
repetition number in this series
0
memorised on
scheduled repetition
scheduled repetition interval
last repetition or drill
Details
No repetitions
Discussion
Do you want to join discussion? Click here to log in or create user.