Saturday, 3 August 2013

Algorithm for Traversing a Link List

Let LIST be a link list, START point to first node in the link list and NULL should be the end of LIST. A pointer variable PTR which point to the node i.e. currently being in process, LINK[PTR] point to the nest node to be process i.e. PTR=LINK[PTR] moved the pointer to the next node in the list.
  1. PTR=START
  2. Repeat Step 3 and 4 while PTR != NULL
  3. Apply process to INFO[PTR]
  4. PTR=LINK[PTR]
  5. Exit

No comments:

Post a Comment