a nonempty array DATA with N numerical values is given. an algorithm to find the location LOC and the value MIN of the smallest element of array DATA. a variable K is gonna be use as counter.
- set K :=1, LOC :=1 and MIN :=DATA[0]. [ initialization ]
- While K<=N, repeat step 3
- IF MIN > DATA[K], then set LOC :=K and MIN :=DATA[K] ELSE K :=K+1.
- Write: LOC, MIN
- Exit.
No comments:
Post a Comment