Follow

Translate

Tuesday, March 8, 2016

Linear Search Algorithm 2.4

Linear Search

Algorithm 2.4: (Linear Search) A Linear Array DATA with N elements and a specific ITEM of information are given. This algorithm finds the location LOC of ITEM in the array DATA or sets LOC = 0.

1.  [Initialize] Set K: = 1 and LOC : = 0.
2.  Repeat Steps 3 and 4 while LOC = 0 and K < N.
3. It ITEM = DATA[K], then: Set LOC: = K.
4. Set K : = K+1. [increments Counter.]
            [End of Step 2 Loop.]
5. [Successful?]
  If LOC = 0, then:
           Write: ITEM is not in the array DATA.
  Else :
          Write: LOC is the location of ITEM.
     [End of If structure.]
6. Exit.
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SOLVE

0 comments:

Post a Comment