Hello Members,

Can anyone please help me out with the concept of INSERTION AND DELETION OF ELEMENTS IN ARRAY..

I have understood the logic behind this, but i am facing problem with the coding thing.. i am not able to get it properly..

can anyone here pls help me out....

I have understood the logic behind this, but i am facing problem with the coding thing.. i am not able to get it properly..

If the problem is in the code then post the code so we may help

If the problem is in the code then post the code so we may help

its the algorithm here..

INSERT(ARR,N,K,ITEM) //N-NO OF ELEMENTS,K-POSITION,ITEM-TO BE INSERTED
SET J:= N
REPEAT STEPS 3 AND 4 WHILE J>=K
SET ARR[J+1]:=ARR[J]
SET J:=J-1
SET ARR[K]:=ITEM
SET N:=N+1
EXIT

Dude..you can use these functions for insertion and deletion..

num : number to insert/delete
pos : position where it will be inserted/deleted

Example taking array of size 5...

Insertion Function:-

void insert(int num, int pos)
  {
   for(int i=4; i>=pos;i--)
     arr[i]=arr[i-1];
   arr[i]=num;
  }

Deletion Function :-

void a_delete(int pos)
  {
   for(int i=pos; i<=4;i++)
   arr[i-1]=arr[i];
   arr[i-1]=0;
  }
commented: Please don't give away answers to people who clearly haven't put in any effort. -4