Data Structure - Searching a linked list algorithm

Searching a linked list

Algorithm

  1. Set ptr:=start
  2. Repeat while ptr!=null.(ptr is not equal to null.)
  3. if item=INFO[ptr], then
    print "Found"
    [end of if structure.]
  4. Set ptr:=link[ptr].
    [end of loop]
  5. [Search unsuccessful]
    print "Not found"
  6. Exit.

Algorithm for traversing a linked list.

Comments

Popular posts from this blog

Theory part introduction

Data structure - Sorting methodes