List traversal is the basic operation where all elements in the list are processed sequentially, one by one. Processing could involve retrieving, searching, sorting, computing the length, and so on.
To traverse a linked list, start from the first node and using the link field traversing can be done till the last node.
Algorithm for traversal:
1. Get the address of the first node, call it curr;
curr = Head.
2. If curr is Null, goto step 6.
3. Process the data in curr. (printing,updating, so on)
4. Move to the next node
curr = curr->link
5. goto step 2
6. stop
0 comments:
Post a Comment