mercredi 18 février 2015

creating a merge sort that accepts linkedlist as an input


Vote count:

0




//Here is some of my code



listnode *mergesort(struct listnode *list){
struct listnode *L, *R, *head;
int i = 0;
head = list;
while (list->next != NULL){
if (i%2 == 0){ //it splits the linkedlist into 2 segments
//it adds the elements in the linked list
// alternatively.
//to a linked list R & L
L=list->next;
list->next = L->next;
i=i+1;
}
else{
R= list->next;
list->next = R->next;
i=i+1;
}
list = list->next;
mergesort(L);
mergesort(R);
return MergeLists(L,R);

}
}


/***I KEEP GETTING SEGMENTATION FAULT, can anybody please help me figure out where the problem is ? Thanks */



asked 1 min ago







creating a merge sort that accepts linkedlist as an input

Aucun commentaire:

Enregistrer un commentaire