Example #1
0
void testbuildlistinsortedorder()
{
	struct node* node = NULL;
	node = buildlistinsortedorder(10);
	printlist(node, "in sorted order ");
	sortedinsert(&node, nn(18));
	printlist(node, " after sorted insert");
}
void insertsort(struct node** headref)
{
	struct node* current = *headref;
	struct node* nextp;
	struct node* ref;

	while(current != NULL){
		nextp = current->next;  //
		sortedinsert(&ref, current);
		current = nextp;
	}
	*headref = ref;
}
Example #3
0
//O(n)
void insertsort(struct node** href)
{
	struct node* cur = *href;
	struct node* result = NULL;
	struct node* next;

	while(cur != NULL)
	{
		next = cur->next;
		sortedinsert(&result, cur);
		cur = next;
	}
	*href = result;
}
Example #4
0
main()
{
	struct node* head =NULL;
	struct node*head2 =NULL;
	int c;
	push(&head,14);
	push(&head,9);
	push(&head,5);
	push(&head,1);
	push(&head2,6);
	print(head); 
	print(head2);
	sortedinsert(&head,head2);
	print(head); 
//	printf("%d\n",c);

}