// 11 — MoveNode() void MoveNodeTest() { struct node* a = BuildOneTwoThree(); // the list {1, 2, 3} struct node* b = BuildOneTwoThree(); MoveNode(&a, &b); // a == {1, 1, 2, 3} // b == {2, 3} }
int main(int argc, const char * argv[]) { //printList(appendNode(&(BuildWithLocalRef()), 2)); //doesn't work? &(2376ut) doesn't work not a lvalue Node* head=BuildOneTwoThree(); appendNodeWithPush(&head, 4); appendNode(&head, 4); appendNode(&head, 4); Node* test5=BuildWithLocalRef(); Push(&test5, 6); insertNth(&test5, 4, 3); //printList(test5); insertSort(&test5); append(&test5, &head); //printList(test5); Node *first=NULL,*second=NULL; //pop(&test5); //split(test5, &first, &second); //printList(first); //printList(second); //removeDuplicates(second); //printList(first); //printList(second); //moveNode(&first, &second); //printList(first); //printList(second); alternatingSplit(test5, &first, &second); //printList(first); //printList(second); //Node* test=shuffleMergeRecursive(first, second); //printList(test); Node* test1=BuildOneTwoThree(); Node* test2=BuildOneTwoThree(); pop(&test2); appendNode(&test2, 7);; appendNode(&test1, 5); //printList(test1); //printList(test2); append(&test1, &test2); //printList(test1); mergeSort(&test1); //printList(test1); Node* t4=BuildOneTwoThree(); Node* t5=BuildOneTwoThree(); appendNode(&t5, 6); appendNode(&t4, 6); appendNode(&t4, 7); appendNode(&t5, 8); Push(&t5, 0); Push(&(t5->next), 1); //printList(t5); //printList(t4); //printList(sortedIntersect(t4, t5)); recursiveReverse(&t5); printList(t5); return 0; }
void MoveNodeTest() { struct node* a = BuildOneTwoThree(); struct node* b = BuildOneTwoThree(); display(a); display(b); MoveNode(&a, &b); display(a); display(b); }
// 17 — Reverse() void ReverseTest() { struct node* head; head = BuildOneTwoThree(); Reverse(&head); // head now points to the list {3, 2, 1} DeleteList(&head); // clean up after ourselves }
// 4 - Pop() void PopTest() { struct node* head = BuildOneTwoThree(); // build {1, 2, 3} int a = Pop(&head); // deletes "1" node and returns 1 int b = Pop(&head); // deletes "2" node and returns 2 int c = Pop(&head); // deletes "3" node and returns 3 int len = Length(head); // the list is now empty, so len == 0 }
/*---------------TEST DRIVER----------------*/ int main(){ struct node* head = BuildOneTwoThree(); PrintList(head); InsertSort(&head); PrintList(head); return 0; }
int main(int argc, char **argv) { struct lnode *head = BuildOneTwoThree(); deletelist(&head); printf("Deleted. Traversing...\n"); traverse(head); printf("Traversal complete\n"); }
/*-------------Test Driver-----------*/ main(){ struct node* a = BuildOneTwo(); struct node* b = BuildOneTwoThree(); struct node* merged = SortedMerge(a,b); struct node* temp = merged; PrintList(temp); }
int main() { struct node* head; int len; head = BuildOneTwoThree(); ReverseTest(); display(head); Push(&head, 13); Push(&(head->next), 42); len = Length(head); printf("%d\n", len); int m = Count(head, 2); //printf("%d\n",m); display(head); DeleteList(&head); struct node* myList = BuildOneTwoThree(); int lastNode = GetNth(myList, 2); //printf("%d\n", lastNode); InsertNthTest(); PopTest(); display(head); MoveNodeTest(); DestroyTest(); getchar(); return 0; }
void PopTest() { struct node* head = BuildOneTwoThree(); int a = Pop(&head); int b = Pop(&head); int c = Pop(&head); int len = Length(head); printf("%d\n", len); }
int main(void) { int len; struct node* head = BuildOneTwoThree(); len = Length(head); printf("list length is %d\n", len); return 0; }
// driver program to test void BasicsCaller() { struct node* head; int len; head = BuildOneTwoThree(); // Start with {1, 2, 3} Push(&head, 13); Push(&(head->next), 42); len = length(head); printf("len = %d\t",len); }
main() { struct node *p; p = BuildOneTwoThree(); print_list(p); return 0; }
void ReverseTest() { struct node* head; head = BuildOneTwoThree(); display(head); Reverse(&head); display(head); DeleteList(&head); }
int test_problem() { struct node *a = BuildOneTwoThree(); int b_spec[3] = {7,13,1}; struct node *b = ListFromArray(b_spec, 3); printf("a: "); PrintList(a); printf("b: "); PrintList(b); struct node *shuffled_list = ShuffleMerge(a, b); printf("shuffled_list: "); PrintList(shuffled_list); }
main() { struct node* head=BuildOneTwoThree(); RecursiveReverse(&head); while(head!=NULL) { printf("%d ",head->data); head=head->next; } }
int main(void) { struct node* head=NULL; head=BuildOneTwoThree(); print(head); head=LinkTest(head,89); print(head); printf("length=%d\n",length(head)); return 0; }
int test_list_one_less() { struct node *a = BuildOneTwoThree(); int b_spec[5] = {7,13,1,99,42}; struct node *b = ListFromArray(b_spec, 5); printf("a: "); PrintList(a); printf("b: "); PrintList(b); struct node *shuffled_list = ShuffleMerge(a, b); printf("shuffled_list: "); PrintList(shuffled_list); }
main() { struct node* head=NULL; struct node* a=BuildOneTwoThree(); struct node* b=BuildOneTwo(); head=SortedMerge(a,b); while(head!=NULL){ printf("%d ",head->data); head=head->next; } }
int main() { struct node *head = BuildOneTwoThree(); int count1; if ( ( count1 = count( head, 2 ) ) > 0 ) { printf( " Ο αριθμός 2 βρέθηκε %d φορές\n", count1 ); } else { printf( "Ο αριθμός 2 δεν βρέθηκε\n" ); } }
void InsertNthTest(void) { struct node *head = BuildOneTwoThree(); InsertNth(&head, 0, 13); InsertNth(&head, 1, 42); InsertNth(&head, 1, 5); DeleteList(&head); }
main() { struct node *a = BuildOneTwoThree(); struct node *b = BuildOneTwoThree1(); struct node *c = ShuffleMerge(a,b); struct node *d = c; while (d != 0) { printf("%d ",d->data); d = d->next; } return 0; }
void BasicsCaller(){ struct node* head; int len; head = BuildOneTwoThree(); Push(&head, 13); Push(&(head->next), 42); len = Length(head); }
int main() { struct node* source = BuildOneTwoThree(); struct node* null = NULL; struct node** aRef = &source; struct node** bRef = &null; AlternatingSplit(source,&source,&null); printf("a1 %d\n",(*aRef)->data); printf("a2 %d\n",(*aRef)->next->data); printf("b1 %d\n",(*bRef)->data); // printf("b2 %d\n",(*bRef)->next->data); return 0; }
int main() { struct node* head = BuildOneTwoThree(); struct node *a, *b; AlternatingSplit( head, &a, &b ); while ( a != NULL ) { printf( "%d\n\n", a->data ); a = a->next; } while ( b != NULL ) { printf( "%d\n", b->data ); b = b->next; } return 0; }
int main() { head = BuildOneTwoThree(head); PrintAll(head); printf("Lenght of the list is %d\n", Length(head)); // insert 6 Append(6, head); PrintAll(head); // insert 5 // delete the whole list }
main() { struct node *p = BuildOneTwoThree(); struct node *a = NULL; struct node *b = NULL; AlternatingSplit(p, &a, &b); struct node *c = a; while (c != 0) { printf("%d ",c->data); c = c->next; } struct node *d = b; printf("\n"); while (d != 0) { printf("%d ",d->data); d = d->next; } return 0; }
int main() { struct node *a = NULL; struct node *b = MakeNode(3); b->next = MakeNode(4); printf("a: "); PrintList(a); printf("b: "); PrintList(b); Append(&a, &b); printf("a: "); PrintList(a); printf("b: "); PrintList(b); struct node *x = BuildOneTwoThree(); struct node *y = MakeNode(4); y->next = MakeNode(5); printf("\nx: "); PrintList(x); printf("y: "); PrintList(y); Append(&x, &y); printf("x: "); PrintList(x); printf("y: "); PrintList(y); return 0; }
int main(int argc, char **argv) { struct lnode *head = BuildOneTwoThree(); int i = nth(head, 2); printf("%d\n", i); }
void GetNthTest(void) { struct node *head = BuildOneTwoThree(); int LastNode = GetNth(head,3); printf("%d\n",LastNode); }