q. write down an algorithm to insert a node in


Q. Write down an algorithm to insert a node in the beginning of the linked list.                        

Ans:

/* structure containing a link part and link part data part */

struct node

{

int data ;

struct node * link ;

} ;

/* Following adds a new node at the beginning of the linked list */

void addatbeg ( struct node **q, int num )

{

struct node *temp ;

/* add new node */

temp = malloc ( sizeof ( struct node ) ) ;

temp -> data = num ;

temp -> link = *q ;

*q = temp ;

}

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: q. write down an algorithm to insert a node in
Reference No:- TGS0156439

Expected delivery within 24 Hours