Deletion Operation in Array(DS)
Prof. Neeraj Bhargava
Kapil Chauhan
Department of Computer Science
School of Engineering & Systems Sciences
MDS University, Ajmer
Deletion Operation 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 For Deletion Operation in Array
 Deletion in the operation in which a value is deleted
at a particular place in an array.
Cont..
In the below diagram , we have deleted E element form the array and rewrite
New array.
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
Example
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.
Assignment
 Explain insertion of element of specific position in
array. Discuss all the steps of algorithm with an
example.

Deletion operation in array(ds)

  • 1.
    Deletion Operation inArray(DS) Prof. Neeraj Bhargava Kapil Chauhan Department of Computer Science School of Engineering & Systems Sciences MDS University, Ajmer
  • 2.
    Deletion Operation inArray  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.
  • 3.
    Algorithm For DeletionOperation in Array  Deletion in the operation in which a value is deleted at a particular place in an array.
  • 4.
    Cont.. In the belowdiagram , we have deleted E element form the array and rewrite New array.
  • 5.
    Algorithm For DeletionIn 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
  • 6.
  • 7.
    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.
  • 8.
    Assignment  Explain insertionof element of specific position in array. Discuss all the steps of algorithm with an example.