Changed a couple of items under arrays.
This commit is contained in:
parent
bb429d2a38
commit
6472d3d1be
36
plan.txt
36
plan.txt
@ -148,7 +148,7 @@ Arrays
|
||||
- Resizing arrays:
|
||||
- https://class.coursera.org/algs4partI-010/lecture/19
|
||||
- https://www.lynda.com/Developer-Programming-Foundations-tutorials/Resizable-arrays/149042/177108-4.html
|
||||
- Implement a vector (mutable array with automatic resizing):
|
||||
* - Implement a vector (mutable array with automatic resizing):
|
||||
* - Practice coding using arrays and pointers, and pointer math to jump to an index instead of using indexing.
|
||||
* - new raw data array with allocated memory
|
||||
- can allocate int array under the hood, just not use its features
|
||||
@ -157,22 +157,22 @@ Arrays
|
||||
* - capacity() - number of items it can hold
|
||||
* - is_empty()
|
||||
* - at(index) - returns item at given index, blows up if index out of bounds
|
||||
* - append(item) - or push(item) - check size of element 2^
|
||||
* - insert(index, item)
|
||||
* - push(item)
|
||||
* - 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
|
||||
- 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
|
||||
* - 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
|
||||
* - Time
|
||||
- O(1) to add/remove at end (amortized for allocations for more space), index, or update
|
||||
- O(n) to insert/remove elsewhere
|
||||
- Space
|
||||
* - Space
|
||||
- contiguous in memory, so proximity helps performance
|
||||
- space needed = (array capacity, which is >= n) * size of item
|
||||
- space needed = (array capacity, which is >= n) * size of item, but even if 2n, still O(n)
|
||||
Linked lists
|
||||
- singly-linked
|
||||
* - Description: https://www.coursera.org/learn/data-structures/lecture/kHhgK/singly-linked-lists
|
||||
@ -189,18 +189,20 @@ Linked lists
|
||||
- push_front
|
||||
- get_front
|
||||
- pop_front
|
||||
- push_back
|
||||
- get_back
|
||||
- pop_back
|
||||
- insert_before(node, item)
|
||||
- insert_after(node, item)
|
||||
- insert_before(node, value)
|
||||
- insert_after(node, value)
|
||||
- size()
|
||||
- is_empty()
|
||||
- find(item) - assume each item is unique
|
||||
- remove(item) - assume each item is unique
|
||||
- find(value) - assume each item is unique
|
||||
- remove(value) - assume each item is unique
|
||||
- reverse - reverses the list
|
||||
- doubly-linked list
|
||||
- Description: https://www.coursera.org/learn/data-structures/lecture/jpGKD/doubly-linked-lists
|
||||
- reverse a singly-linked list
|
||||
- implement:
|
||||
- same as above for singly linked list
|
||||
- push_back()
|
||||
- get_back()
|
||||
- pop_back()
|
||||
Stacks
|
||||
- see: https://class.coursera.org/algs4partI-010/lecture
|
||||
- https://www.coursera.org/learn/data-structures/lecture/UdKzQ/stacks
|
||||
|
Loading…
x
Reference in New Issue
Block a user