Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.

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

^^ 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

^^ 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"

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 |

Do you want to join discussion? Click here to log in or create user.