Last active
August 2, 2020 01:39
-
-
Save EricGustin/a546529f73125c86f8815f558713f095 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Operation Example Big O Time Complexity | |
| Index: lst[i] O(1) | |
| Assign: lst[i] = 2 O(1) | |
| Length: len(lst) O(1) | |
| Append: lst.append(i) O(1) | |
| Pop: lst.pop() O(1) | |
| Clear: lst.clear() O(1) | |
| Slice: lst[start:end] O(end - start) | |
| Extend: lst.extend(iterable) O(length of iterable) | |
| Construct: lst = list([iterable]) O(length of iterable) | |
| Insert: lst.insert(i, elem) O(n) | |
| Delete: del lst[i] O(n) | |
| Remove: lst.remove(...) O(n) | |
| Containment: x in/not in lst O(n) | |
| Copy: lst.copy() O(n) | |
| Pop at beginning: lst.pop(0). O(n) | |
| Min/Max: min(lst)/max(lst) O(n) | |
| Reverse: lst.reverse() O(n) | |
| Iteration: for elem in lst: O(n) | |
| Sort: lst.sort() O(n*log(n)) | |
| Multiply: lst * 5 O(n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment