In Class: Week 13
Create a week13 subdirectory in your cs21/class directory:
% cd cs21/class
% mkdir week13
Then, from within your week13 subdirectory copy over some python files
from my public directory:
% cd week13
% cp ~newhall/public/cs21/week13/* .
We are going to implement several method functions of the LinkedList
class and test them as we go.
- insertAtHead(val): add a new node at the front of the linke list
- __str__: complete this method that will print out the linked list
- insertAtTail(val): add a new node to the end of the linked list
- findElement(val): find a matching element in the linked list, returns
a reference to the Node with a matching data field or None if no matching
value exists in the linked list
- insertSorted(val): add a new node in sorted order into the linked list.
We will use insertion Sort to find the correct insertion spot for the
- removeFromHead(): remove the first element from the linked list
and returns the value of its data field or None if the list is empty
- removeFromTail(): remove the last element from the linked list and
returns the value of its data field or None if the list is empty