The Method of Modifying a Linked List


  1. Test any necessary pre-conditions.

  2. Create any additional nodes and pointers that are needed for the task.

  3. Use the pointers to locate the position(s) in the list where the change will take place.

  4. Divide the task into distinct cases.

    • Begin with the most general case.
    • Work down to the least general case.

  5. Draw a picture of the structure before the modifications take place.

  6. Label each relevant pointer and node in the drawing.

  7. Draw a picture of the structure after the modifications take place.

  8. For the pointers which were modified, write the assignment statements that will modify them.

  9. Arrange the assignment statements in the correct order.

  10. Consolidate the cases.

    • Determine what code is common to all cases.
    • Write the common code either before or after dividing into cases.
    • Combine cases that use the same code into a single case.

  11. Distinguish the cases.

    • Find conditions that are unique to each case (based on the values of variables).
    • Write the if statements and the code to handle the separate cases.

  12. Write any other statements necessary to complete the task.

  13. Test the code.



Return to Lectures page

This page was last modified on Feb 28, 2001

URL: http://people.hsc.edu/faculty-staff/robbk/Coms262/Lectures/TheMethod.html