A good algorthm usually comes together with a set of good data structures that allow the algorithm to manipulate the data efficiently.
Create your own LinkedList class for storing integers which should include two methods:
- add(number) - Add a new Node to the end of the list with a value of number. Nothing needs to be returned.
- get(index) - Return the value of the Node at position
index
in the List. - Write step by step
- Video: https://www.coursera.org/lecture/data-structures/singly-linked-lists-kHhgK
Implement the following two methods in your own LinkedList class:
- add_at(index, item) - Add an item to a specific location in the list. The index will be a positive integer that represents the index where you should insert item. Zero is the position of the first element of the list. remove(index) - Remove an item from a specific location in the List.
- You should also implement a private helper method get_node(index) to return the Node at a specific index.
You should have already completed these two methods in the previous linkedlist11:
- add(number) - Add number to the end of your LinkedList.
- get(index) - Get the number located at index.
Video : https://www.coursera.org/lecture/data-structures/singly-linked-lists-kHhgK