- Compare abstract data types and concrete data structures
- Abstract data types: list
- Concrete data structures: array, dynamic array (resizable array, vector), linked list
By this end of this lesson, students should be able to...
- Practice more advanced techniques with lists and arrays
- Implement list manipulation methods such as insert and replace
- Review Make School's array and linked list slides
- Watch Make School's array and linked list video lecture
- Read Vaidehi Joshi's articles on linked lists, part 1: how they work and part 2: complexity analysis and comparison to arrays with excellent, beautiful drawings
- Watch HackerRank's linked list video
- Watch Harvard's array video, singly linked list video, and doubly linked list video
- Play with VisuAlgo's interactive linked list visualization
- Add new features to
LinkedList
class using linked list starter code:- Add
size
property that tracks list length in constant running time - Implement
get_at_index(index)
- returns the item atindex
in the list - Implement
insert_at_index(index, item)
- insertsitem
atindex
(all items afterindex
are moved down) - Implement
replace(old_item, new_item)
- replacesold_item
in the list withnew_item
using the same node - Run
python linkedlist.py
to testLinkedList
class instance methods on a small example - Run
pytest linkedlist_test.py
to run the linked list unit tests and fix any failures
- Add
- Annotate methods with complexity analysis of running time and space (memory)
- Implement
DoublyLinkedList
class withBinaryNode
objects, which have bothnext
andprevious
properties - Write unit tests for to ensure the
DoublyLinkedList
class is robust- Include test cases for each class instance method and property
- Annotate methods with complexity analysis of running time and space (memory)
- Fill out attendance, challenges completed, etc.
- Differences between Linked List and Array
- can access arbitrary address of array in constant time - so can find middle element with binary search.
- In Linked List, you can't access the middle directly (have to traverse from beginning) so binary search would not work.
- Similarity between Array and Linked List?
- they both are ordered
- both implements methods: insert, append, prepend, read
- List Abstract Data Type - ADT
- Arrays and Linked List are concrete Data Structures that can implement the ADT / Interface / Protocol
Implement methods on linked list class so interface is the same as an array. [On repo - includes example, unit tests, starter code]