Deleting From a Linear Array
Algorithm: (Deleting From a Linear Array) DELETE (LA, N, K, ITEM)
Here LA is a linear array with N elements and K is a positive integer such that K < N. This algorithms Deletes an element ITEM into the Kth Element LA.
1. Set ITEM : = LA[K].
Algorithm: (Deleting From a Linear Array) DELETE (LA, N, K, ITEM)
Here LA is a linear array with N elements and K is a positive integer such that K < N. This algorithms Deletes an element ITEM into the Kth Element LA.
1. Set ITEM : = LA[K].
2. Repeat for J = K to N - 1:
[Move J + 1st element upward.] Set LA[J] : = LA[J + 1].
[End of Loop].
3. [Reset the number N of elements in LA.] Set N : = N - 1.
4. Exit.
0 comments:
Post a Comment