Trans versing and Insertion Algorithm
Link will be apear in 15 seconds.
Well done! you have successfully gained access to Decrypted Link.
Trans versing Algorithm:
§ Traversing operation means visit
every element once.
e.g. to print, etc.
§ Example algorithm:
1. [Assign counter]
K=LB
// LB = 0
2. Repeat step 2.1 and 2.2 while K <=
UB // If LB = 0
2.1 [visit
element]
do
PROCESS on LA[K]
2.2 [add
counter]
K=K+1
3. end repeat step 2
4. exit
Insertion
Algorithm:
Insert item
at the back is easy if there is a space. Insert item in the middle requires the
movement of all elements to the right.
Example algorithm:
§ INSERT(LA, N, K, ITEM)
§ //LA is a linear array with N element
§ //K is integer positive where K <
N and LB = 0
§ //Insert an element, ITEM in index K
§ 1.
[Assign counter]
§ J = N – 1; //
LB = 0
§ 2.
Repeat step 2.1 and 2.2 while J >= K
§ 2.1 [shift to the right all elements from J]
§ LA[J+1]
= LA[J]
§ 2.2 [decrement counter] J = J – 1
§ 3.
[Stop repeat step 2]
§ 4.
[Insert element] LA[K] = ITEM
§ 5.
[Reset N] N = N + 1
§ 6.
Exit