In Class: Week 13


We are going to continue using the files from week 12 this week. If you have not already done so, create a week12 subdirectory in your cs21/class directory and copy over some starting point files:

    $ cd
    $ cd cs21/class
    $ pwd
      /home/your_user_name/cs21/class
    $ mkdir week12
    $ cd week12
    $ pwd
      /home/your_user_name/cs21/class/week12
    $ cp ~newhall/public/cs21/week12/* .
  

We are going to implement several method functions of the LinkedList class and test them as we go.
  1. insertAtHead(val): add a new node at the front of the linke list
  2. insertAtTail(val): add a new node to the end of the linked list
  3. __str__: complete this method that will create a string version of the linked list. We will try calling it from main, by calling print str(list)
  4. 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
  5. 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 new element
  6. removeFromHead(): remove the first element from the linked list and returns the value of its data field or None if the list is empty
  7. removeFromTail(): remove the last element from the linked list and returns the value of its data field or None if the list is empty