Created
September 21, 2015 14:48
-
-
Save tanvir002700/8ad483b3e76536dc06aa to your computer and use it in GitHub Desktop.
Linked List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void add(int pos,int val) | |
{ | |
node *temp=new node(); | |
temp->data=val; | |
if(pos==0) | |
{ | |
Size++; | |
temp->next=Head; | |
Head=temp; | |
return; | |
} | |
node *left,*right; | |
right=Head; | |
int p=0; | |
while(right!=NULL and p<pos) | |
{ | |
left=right; | |
right=right->next; | |
p++; | |
} | |
if(right!=NULL) | |
{ | |
Size++; | |
left->next=temp; | |
left=temp; | |
left->next=right; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment