Deleting an element from an array




Algorithm:



(Deleting from a 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 algorithm deletes the Kth element from LA.

1. Set ITEM = LA[K]

2. Repeat for J=K to N-1:
[Move J+ 1st element upward.] Set LA[J]=LA[J1+1]
[End of loop.]

3. [Reset the number N of elements in LA.] Set N= N-1.

4. Exit



Comments

Popular posts from this blog

Node.js Cheat Sheet

Codeigniter ! Simple But Powerful

Enhancing Supply Chain Security and Cloud-Native Development with Chainguard