In Class: Week 14


Create a week14 subdirectory in your cs21/class directory:

      % cd 
      % cd cs21/class
      % pwd
        /home/your_user_name/cs21/class
      % mkdir week14       
	
Then, from within your week14 subdirectory copy over some python files from my public directory:
    % cd week14
    % pwd
      /home/your_user_name/cs21/class/week14

    % cp ~newhall/public/cs21/week14/* .
    % ls
		  linkedlist.py
	

This version of linkedlist.py has implementations for the method functions we did last week. We are going to complete insertSorted today. The algorithm is:
insertSorted(elm):

(0) Create a new node with elm as it data field
(1) If the list is empty, add this as the new head and tail node 
(2) Else:
    (1) Find the insertion spot
        we need to traverse with curr and prev pointers
    (3) Insert it into the linked list
         (a) if the insertion spot is before head, set new node's next to 
             point to head, and head to point to new node
         (b) if the insertion spot is after tail, set tail's next to 
             point to new node, and tail to point to new node
         (c) if the insertion spot is in the middle, need to change the
             new node's next field to point to the node after the insertion
             spot, and change the next field of the node immediately before 
             the insertion spot to point to the new node