In Class Week14

  1. Create a week14 subdirectory and copy over this file into it:
         cp /home/newhall/public/cs21/week14/linkedlist.c .
         

  2. Open up linkedlist.c, take a look at comment (1), and implement the GetNode function that it describes. The linked-list is represented by a linkedList struct with a head pointer, a tail pointer, and a count of the number of elements in the linked list.

  3. Once that works, take a look at comment (2), and using your GetNode function, build a linked list with a head and tail pointer such that new nodes are added to the end of the list. For example, if the user enters 6, 12, 5, and 4, the linked list should look like:
    list:
    --------------       ---------     ---------     ---------      ---------
    | head   *---|------>|   6   |     |  12   |     |  5    |      |   4   | <-------| 
    ---------------      ---------     ---------     ---------      ---------         |
    | tail   *---|---    |    *--|---->|    *--|---->|    *--|----> |    *--|---|     |
    --------------   |   ---------     ---------     ---------      ---------         |
    | num_elms: 4|   |                                                                |
    --------------   |                                                                |
                      -----------------------------------------------------------------
    

  4. Write a function to print out the elements in the linked list, as described in comment (3) in the code.

  5. Write and test a function to free a linked-list as described in comment (4).