English

Write an Algorithm for Traversing Linear Array - Computer Science 1

Advertisements
Advertisements

Question

Write an algorithm for Traversing Linear Array.

Solution

Traversing: Traversing an array means accessing each element of an array only at once so that
it can be processed.

Algorithm for traversing a linear array:

LA = linear array

LB = lower bound of an array

UB = upper bound of an array

PROCESS – operation of each element of LA

1) [Initialize [counter]]

     Set K: = LB

2) Repeat steps 3 and 4 while K<=UB

3)  [Visit element]

      Apply PROCESS to LA [K]

4)  [Increase Counter]

      Set K: = K+1 [End of step 2 loop]

5) Exit

shaalaa.com
Basic Data Structures (Stack, Queue, Dequeue)
  Is there an error in this question or solution?
2017-2018 (March)

APPEARS IN

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×