Algorithm for Deletion in Array
It is a process of deleting a particular element from an array. If an element to be deleted ith location then all elements from the (i+1)th location we have to be shifted one step towards left.
So (i+1)th element is copied to ith location and (i+2)th to (i+1)th location and so on.
Algorithm: In this algorithm a value is being deleted from ith location of an array Reg[N]. Let us assume that last element in the array is at Mth position.
2. While (Back<M) repeat 3 and 4
3. Reg[Back]= Reg[Back+1]
4. Back= Back+1
1. Back=i => Back=5
2. While(Back<M) repeat step 3 to 4
=> 5<8 true
Now Back =6
again step 3.
step 4: Back=Back+1 =>7
again step 3 until Back<M