This commit is contained in:
tiendung 2023-05-27 00:04:19 +07:00
parent 3a11b93f88
commit 237665f513
1 changed files with 5 additions and 5 deletions

View File

@ -598,17 +598,17 @@ if you can identify the runtime complexity of different algorithms. It's a super
- [x] push(item)
- [x] insert(index, item) - inserts item at index, shifts that index's value and trailing elements to the right
- [ ] prepend(item) - can use insert above at index 0
- [ ] pop() - remove from end, return value
- [ ] delete(index) - delete item at index, shifting all trailing elements left
- [x] pop() - remove from end, return value
- [x] delete(index) - delete item at index, shifting all trailing elements left
- [ ] remove(item) - looks for value and removes index holding it (even if in multiple places)
- [ ] find(item) - looks for value and returns first index with that value, -1 if not found
- [ ] resize(new_capacity) // private function
- when you reach capacity, resize to double the size
- when popping an item, if size is 1/4 of capacity, resize to half
- [ ] Time
- [x] Time
- O(1) to add/remove at end (amortized for allocations for more space), index, or update
- O(n) to insert/remove elsewhere
- [ ] Space
- [x] Space
- contiguous in memory, so proximity helps performance
- space needed = (array capacity, which is >= n) * size of item, but even if 2n, still O(n)
@ -621,7 +621,7 @@ if you can identify the runtime complexity of different algorithms. It's a super
- [ ] [[Review] Linked lists in 4 minutes (video)](https://youtu.be/F8AbOfQwl1c)
- [ ] [C Code (video)](https://www.youtube.com/watch?v=QN6FPiD0Gzo)
- not the whole video, just portions about Node struct and memory allocation
- [ ] Linked List vs Arrays:
- [x] Linked List vs Arrays:
- [Core Linked Lists Vs Arrays (video)](https://www.coursera.org/lecture/data-structures-optimizing-performance/core-linked-lists-vs-arrays-rjBs9)
- [In The Real World Linked Lists Vs Arrays (video)](https://www.coursera.org/lecture/data-structures-optimizing-performance/in-the-real-world-lists-vs-arrays-QUaUd)
- [ ] [Why you should avoid linked lists (video)](https://www.youtube.com/watch?v=YQs6IC-vgmo)