Exercises: Doubly Linked Lists
with Header and Trailer Nodes

     struct node 
     {
          int info;
          node *prev, *next;
     };

     node* L;

    

Directions: Given the definitions above, write the following functions based on the stated pre- and post-conditions.

1.   void insertDouble(node* L, int grade) 
     // pre-condition:  L is doubly linked, in ascending order, contains numeric grades, 
     //			delimited by a header node containing a negative integer and 
     //			a trailer node containing a 3-digit integer.
     // post-condition: an integer grade is inserted into L at its appropriate location
     {
          node* newnode = ____________________;
          newnode->info  = ____________________;
          node* trav          = L->next; 
          while (grade  ___  ______________________ ) 	// seek insertion position
          {
               trav = trav->next; 
          }
          trav->_______ ->next = newnode; 		// link before newnode
          newnode->prev  = __________________;  	 
          _____________ = trav; 			// link after newnode
          ______________  = ______________; 		
     }


2.   void removeDouble(node* L, int  grade) {
     // pre-condition:  Same as above
     // post-condition: Integer grade known to exist in L is deleted (no duplicates) 
     {




Continue to:  Unit 6  / Prev  / Next