Create sorted linked list

Anyone tell me what is meaning of following definition?
Write a program to create a sorted singly linked list.

is it when we create node at that time node will be in sorted order or after creating linked list sorting will be performed on list?
means whenever you add a node the linked list, the resulting linked list will always be sorted. Thus nodes should be inserted in sorted order.
k thanks can you give me logic for that?
i have tried but can't perform sorting
i have write code but not proper can you suggest me?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
void create (int num)
{
	struct list *temp,*current;
	if(start==NULL) //for first node
	{
		temp=(struct list*)malloc(sizeof(struct list));
		temp->data=num;
		temp->next=NULL;
		start=temp;
	}
	else
	{
	current=start;
	while(current!=NULL)
	{
		if(current->next->data>num)
		{
			temp=(struct list*)malloc(sizeof(struct list));
			temp->data=num;
			temp->next=current->next;
			current->next=temp;
			return;
		}
		current=current->next;
	}
}
Last edited on
Topic archived. No new replies allowed.