Thread: Straight Insertion Sort and Double-Linked List?
hello!
have sort double-linked list via straight insertion sort. problem seem somehow wrong. got segmentation fault after third time cycle starts, using numbers: 3 5 4 2 7 6 8 9 1
help. i'm more looking hint of i'm doing wrong ready-to-use code. source attached below...
use debugger gdb step though code.
ran through list 2<->1, output:
program received signal sigsegv, segmentation fault.
0x080494a6 in straightinsertionsort () @ kpp.cpp:203
warning: source file more recent executable.
203 if(p->next->prev||p->prev) p->next->prev=p->prev;
(gdb) p p->next
$4 = (linked_list *) 0x0
p->next null pointer p->next->prev undefined
on first sight algorithm seems strange too, insertion sort need add_before? if remember correctly have swap links
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Straight Insertion Sort and Double-Linked List?
Ubuntu
Comments
Post a Comment