Algorithms for array traversal,insertion and deletion are shown below separately.
ALGORITHM : (Traversing of Linear Array) Here Arr is a linear array with lower bound L and upper bound U
1.[Initialize Counter] Set K=L.
2.Repeat steps 3 and 4 while K<=U
3.Print Arr[K].
4.[Increase Counter] Set K=K+1.
5.Exit
ALGORITHM :(Inserting into a Linear Array) INSERT(Arr,N,K,ITEM)
Here Arr is a linear array with N elements ,K is positive integer such that K<=N and ITEM is the element to be inserted.
1.[Initialize Counter] Set I=N.
2.Repeat steps 3 and 4 while I>=K.
3.Set Arr[I+1]=Arr[I].
4. [Decrease Counter] Set I=I-1.
5.[Inserting ITEM] Set Arr[K]=ITEM.
6.[Reset Number Of Elements].Set N=N+1.
7.Exit
ALGORITHM :(Deleting From Linear Array) DELETE(Arr,N,K)
Here Arr is a linear array with N elements ,K is positive integer such that K<=N and Kth element is to be deleted.
1.[Initialize Counter] Set I=K.
2.Repeat steps 3 and 4 while I=N-1.
3.Arr[I]=Arr=[I+1].
4.[Increase Counter]Set I=I+1.
5.[Reset Number Of Elements].Set N=N-1.
6.Exit.
If you have any suggestions regarding this post, please comment below in the comment section.