➡
Here A is an unsorted array stored in memory with N elements.This algo inserts a data element at the loc position in an array.
INSERT_UNSORT() :
A is unsorted array with N elements. LOC is the location where ITEM have to be inserted.
Step I : [ initialize Counter ] Set I = N
Step II : Repeat While ( I >= LOC )
Step III : [ Move elements ] Set A[I + 1] = A[I]
Step IV : [ Decrease counter ] Set I = I – 1
[ End of while loop ]
Step V : [ Insert Element ] Set A[ LOC ] = ITEM
Step VI : [ Reset N ] Set N = N + 1
Step VII : Exit