Answer
-Last ← the last name to be printed Finished ← false Current Pointer ← the head pointer;
-while (Current Pointer not NIL and Finished = false) do (print the entry pointed to by Current Pointer)
- if (the name just printed = Last) then (Finished ← true) Current Pointer ← the value in the pointer cell in the entry pointed to by Current Pointer)
Work Step by Step
Modifying the procedure in Figure so that it stops printing once a particular name has been printed.
-Last ← the last name to be printed Finished ← false Current Pointer ← the head pointer;
-while (Current Pointer not NIL and Finished = false) do (print the entry pointed to by Current Pointer,
- if (the name just printed = Last) then (Finished ← true) Current Pointer ← the value in the pointer cell in the entry pointed to by Current Pointer)