Array is a container which can hold a fix number of items and these items should be of the same type. Most of the data structures make use of arrays to implement their algorithms.
Traverse − print all the array elements one by one.or process the each element one by one .
Let A be a collection of data elements stored in the memory of the computer. Suppose we want to print the content of each element of A or suppose we want to count the number of elements of A with given property. This can be accomplished by traversing A, that is, by accessing and processing (frequently called visiting) each element of An exactly once.
Algorithm
Step 1 : [Initialization] Set I = LB
Step 2 : Repeat Step 3 and Step 4 while I < = UB
step 3 : [ processing ] Process the A[I] element
Step 4 : [ Increment the counter ] I = I + 1
[ End of the loop of step 2 ]
Step 5: Exit
(Here LB is lower Bound and UB is Upper Bound A[ ] is linear array )
0 comments:
Post a Comment