Skip to content

Instantly share code, notes, and snippets.

@tanvir002700
Created September 21, 2015 14:48
Show Gist options
  • Save tanvir002700/8ad483b3e76536dc06aa to your computer and use it in GitHub Desktop.
Save tanvir002700/8ad483b3e76536dc06aa to your computer and use it in GitHub Desktop.
Linked List
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