Question: + Here is Mylist.h #include struct _SingleList { double Item; struct _SingleList *Next; }; typedef struct _SingleList SingleList; void PrintList(SingleList *Node); void InsertNodeAfter(SingleList *Node, SingleList
+ Here is Mylist.h
#include
struct _SingleList { double Item; struct _SingleList *Next; };
typedef struct _SingleList SingleList;
void PrintList(SingleList *Node);
void InsertNodeAfter(SingleList *Node, SingleList *Insert); void RemoveNodeAfter(SingleList *Node);
void RemoveAtRoot(SingleList *Root); void InsertAtRoot(SingleList *Root, SingleList *NewRoot);
+ Here is main.c
#include
int main() {
SingleList FourthNode = {7.1,NULL}; SingleList InitialRoot = {5.2,&FourthNode}; SingleList *head = &InitialRoot; printf("Initial List: "); PrintList(head); printf(" ");
SingleList NewRoot = {9.4, NULL}; printf("List after inserting %.1lf at the head: ",NewRoot.Item); InsertAtRoot(&InitialRoot, &NewRoot); head = &NewRoot; PrintList(head); printf(" ");
SingleList FifthNode = {0.5, NULL}; printf("Going to insert %.1lf at end of the list: ",FifthNode.Item); InsertNodeAfter(&FourthNode, &FifthNode); PrintList(head); printf(" ");
SingleList ThirdNode = {3.8, NULL}; printf("Inserting %.1lf in the middle of the list: ", ThirdNode.Item); InsertNodeAfter(&InitialRoot,&ThirdNode); PrintList(head);
SingleList LastNewRoot = {3.14, NULL}; printf("Exchanging %.1lf with %.2lf: ",NewRoot.Item, LastNewRoot.Item); InsertNodeAfter(&FifthNode, &LastNewRoot); /*Begin the exchanging process of root nodes*/ LastNewRoot.Next = &InitialRoot; FifthNode.Next = &NewRoot; NewRoot.Next = NULL; head = &LastNewRoot; /*End the exchanging process of root nodes*/ PrintList(head); printf(" ");
printf("Removing %.1lf from the list: ", FourthNode.Item); RemoveNodeAfter(&ThirdNode); PrintList(head); if(1){ printf(" "); } return 0; }
+ Here is ListFunction.c
#include
void PrintList(SingleList *Node) { SingleList *Temp = Node; while (Temp != NULL) { printf("%.2lf ",Temp->Item); Temp = Temp->Next; } printf(" "); return; }
void InsertNodeAfter(SingleList *Node, SingleList *Insert) { if(Node == NULL) { return; }
if(Insert == NULL){ return; }
if(Node->Next == NULL) { Node->Next = Insert; } else { Insert->Next = Node->Next; Node->Next = Insert; } return; }
void RemoveNodeAfter(SingleList*Node) { if(Node->Next == NULL) { return; }
if(Node->Next->Next == NULL) { Node->Next = NULL; } Node->Next = Node->Next->Next; return; }
void RemoveAtRoot(SingleList *Root){ if(Root->Next == NULL) { return; } Root->Next = NULL; return; }
void InsertAtRoot(SingleList*Root,SingleList*NewRoot) { if (Root == NULL) { return; }
if(NewRoot == NULL) { return; } NewRoot->Next = Root; return; }
Question: Write a report describe each function in ListFunctions.c and describe what main.c does in a series of short paragraphs. For each function, you should write a paragraph. In each of the paragraphs for ListFunctions.c you should describe what the function does, inputs, and outputs. In main, you should describe the flow of the program as well as mention what functions are called, data types used (and data types that are created), and plain English definition of what the program does. To expand more on plain English, it means that you should describe the program in a non-technical way, such that, for example, your parents (if they are not engineers) could understand what the program does. Each paragraph should be 3 sentences, give or take. This is a technical paper, do not spend time with metaphors or describing the history of c, or linked lists. Cut straight to the point and give information that is useful, like how to use the code and what it does.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
