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

Assignment Help:

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);

}


Related Discussions:- Programme in c to create a single linked list

The number of different directed trees with 3 nodes, The number of differen...

The number of different directed trees with 3 nodes are ?? The number of disimilar directed trees with three nodes are 3

Darw a flowchart to inputs top speeds of 5000 cars, Write an algorithm in t...

Write an algorithm in the form of a flowchart that: inputs top speeds (in km/hr.) of 5000 cars Outputs fastest speed and the slowest speed Outputs average (mean) s

Multiplication, Implement multiple stacks in a single dimensional array. Wr...

Implement multiple stacks in a single dimensional array. Write algorithms for various stack operations for them.

Indexed sequential file organisation, When there is requirement to access r...

When there is requirement to access records sequentially by some key value and also to access records directly by the similar key value, the collection of records may be organized

Data Structure, Ask consider the file name cars.text each line in the file ...

Ask consider the file name cars.text each line in the file contains information about a car ( year,company,manufacture,model name,type) 1-read the file 2-add each car which is repr

Properties of red- black tree, Any Binary search tree has to contain follow...

Any Binary search tree has to contain following properties to be called as a red- black tree. 1. Each node of a tree must be either red or black. 2. The root node is always b

State the term access restrictions - container, What is Access Restriction...

What is Access Restrictions Structured containers with access restrictions only allow clients to add, remove and examine elements at certain locations in their structure. For

String pattern matching, Document processing is quickly becoming one of the...

Document processing is quickly becoming one of the dominant functions of computers. Computers are utilized to edit, search & transport documents over the Internet, and to display d

Write procedure to the insert a node into the linked list, Q. Write a proce...

Q. Write a procedure to the insert a node into the linked list at a particular position and draw the same by taking an example?

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd