Embed presentation
Download to read offline




![Algorithm For Deletion In An Array
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.
Steps
1. Back=i
2. While (Back<M) repeat 3 and 4
3. Reg[Back]= Reg[Back+1]
4. Back= Back+1
5. M=M-1
6. End](https://image.slidesharecdn.com/deletionoperationinarrayds-200514060327/85/Deletion-operation-in-array-ds-5-320.jpg)

![Explaination
Steps
1. Back=i => Back=5
2. While(Back<M) repeat step 3 to 4
=> 5<8 true
3. Reg[Back]=Reg[Back+1]
Reg[5]=>Reg[6]=> reg[5]=20
4. Back=Back+1
Now Back =6
again step 3.
Reg[6]=Reg[6=1]
= 28
step 4: Back=Back+1 =>7
again step 3 until Back<M
5. M=M-1
=8-1=>7
6. End.](https://image.slidesharecdn.com/deletionoperationinarrayds-200514060327/85/Deletion-operation-in-array-ds-7-320.jpg)

Deletion operation in an array involves shifting elements to the left to fill the space left by the deleted element. The algorithm shifts each element from index i+1 to the left by one index to overwrite the deleted element at index i. It then decrements the last index of the array by one to account for the reduced length. For example, to delete element E from the array, element F would shift to index 3, G to index 4, and so on, and the last index would decrement from 8 to 7.




![Algorithm For Deletion In An Array
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.
Steps
1. Back=i
2. While (Back<M) repeat 3 and 4
3. Reg[Back]= Reg[Back+1]
4. Back= Back+1
5. M=M-1
6. End](https://image.slidesharecdn.com/deletionoperationinarrayds-200514060327/85/Deletion-operation-in-array-ds-5-320.jpg)

![Explaination
Steps
1. Back=i => Back=5
2. While(Back<M) repeat step 3 to 4
=> 5<8 true
3. Reg[Back]=Reg[Back+1]
Reg[5]=>Reg[6]=> reg[5]=20
4. Back=Back+1
Now Back =6
again step 3.
Reg[6]=Reg[6=1]
= 28
step 4: Back=Back+1 =>7
again step 3 until Back<M
5. M=M-1
=8-1=>7
6. End.](https://image.slidesharecdn.com/deletionoperationinarrayds-200514060327/85/Deletion-operation-in-array-ds-7-320.jpg)
