Programme in c to create a single linked list, Data Structure & Algorithms

Q. Write  down a   programme  in  C  to  create  a  single  linked  list also  write the functions to do the following operations

(i)  To insert a new node at the end

(ii) To delete the first node                                                                                                                                     

Ans:

//Create a single list

struct node

{

int data;

struct node *link

}

struct node *p,*q;

//Inserting a node at the end(append)

append(struct node **q,int num)

{

struct node *temp; temp=*q; if(*q==NULL)

{

*q=malloc(sizeof(struct node *));

temp=*q;

}

else

{

while(temp        link!=NULL)

temp=temp   link;

temp   link = malloc(sizeof(struct node *));

temp=temp   link;

}

Temp   data=num;

temp     link=NULL;

}

//Delete the first node delete(struct node *q,int num)

{

struct node *temp;

temp=*q;

*q=temp   link;

free(temp);

}

Posted Date: 7/10/2012 7:08:48 AM | Location : United States







Related Discussions:- Programme in c to create a single linked list, Assignment Help, Ask Question on Programme in c to create a single linked list, Get Answer, Expert's Help, Programme in c to create a single linked list Discussions

Write discussion on Programme in c to create a single linked list
Your posts are moderated
Related Questions
I need a person who has a good background in using R. Studio? In adition, a person who is good in using algorithms.

Multiplication Method: The multiplication method operates in 2 steps. In the 1ststep the key value K is multiplied by a constant A in the range O

Preconditions assertion A precondition is an assertion which should be true at the initiation of an operation. For instance, a square root operation can't accept a negative a

You are supposed to do the following: Write a parallel implementation of the raytracer using pthreads. Measure and compare the execution times for (i) the sequential ver

creation,insertion,deletion of header linked list using c.

For a queue a physical analogy is a line at booking counter. At booking counter, customers go to the rear (end) of the line & customers are attended to several services from the fr

a) Given a digraph G = (V,E), prove that if we add a constant k to the length of every arc coming out from the root node r, the shortest path tree remains the same. Do this by usin

basic calculation for algorith.

3. A function to convert a complex number in algebraic form to a complex number in phasor form

A  BST is traversed in the following order recursively: Right, root, left e output sequence will be in In Descending order