***Welcome to ashrafedu.blogspot.com * * * This website is maintained by ASHRAF***

    Friday, September 9, 2022

    Linked List traversal

    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

     



     

    No comments:

    Post a Comment

    Prim’s algorithm for finding MST (Minimum Spanning Tree)

    Prim's algorithm to find minimum cost spanning tree uses the greedy approach. Prim's algorithm, in contrast with Kruskal's algor...