Delete Item from an Array :


ITEM is the element which has to be deleted from location LOC . I is set to LOC from where Item is to be deleted and it iterates to total number of elements i.e. N .

DELETE () :
Here A is a linear array with N elements. LOC is the location and ITEM  is to be deleted.

Step I    : [ Assign the element to be deleted ]  Set ITEM = A[ LOC ]
Step II  : Repeat For I = LOC to N
Step III : Set A[I] = A[I+1]
[ End of For loop ]
Step IV : [ Reset N ]  Set N = N – 1
Step V  : Exit.

Leave a comment