Hi friends,

i have to delete a node in a link list and the prototype for the delete function is like this
void deleteNode(struct node**, int pos). "Pos " is the position of the specified node in the list.
And have to write it with all boundry condiotions.

Help me

Start with a loop which searches forward 'pos' nodes or until the end of the list.
Can you do that much?

First tell which type on Link List you are using: Singly, Doubly, Circular etc..

## All 5 Replies

Start with a loop which searches forward 'pos' nodes or until the end of the list.
Can you do that much?

First tell which type on Link List you are using: Singly, Doubly, Circular etc..

this is the function...

void deletenode(struct **start, int pos)
{
if(*start == NULL )
{

well it is a singly linked list
this is the function...

``````void deletenode(struct **start, int pos)
{
struct node *tmp;
int i;
//test if the node is empty
if(*start == NULL )
{
printf("List empty");
return ;
}

//test if the node is 1st node
tmp=*start;
{
if(pos==1)
{
free(*start);
*start=null;
return;
}
printf("not enough node");
return ;
}

for(i=1;i<(pos-1);i++)
{
//if end comes before pos, then this will take care
{
printf("Not enough nodes in the list");
return ;
}
}

}``````

well this much i did, can any one correct the solution and handle the condition when the node to be deleted is the last node

``````void deletenode(struct **start, int pos)
{
struct node *tmp;
int i;

if(*start == NULL) {
printf("\nThe List is Empty");

return;
}

//Here check other conditions for invalid pos  etc.

tmp = *start;

for(i=1; i<=(pos-1); i++) {
}

struct node *nod_to_del;