Question
In C, using this structure: struct node{ int data; int next; int valid; }; I'm trying to create a function with parameters listed below. I'm
In C, using this structure:
struct node{
int data;
int next;
int valid; };
I'm trying to create a function with parameters listed below. I'm having difficulty getting it to work. One of the assignment requirements is to use "int MYNULL = -1;" as NULL.
int add(struct node*LL,int number)
This should add a node the linked list, to store number in the list. The list should always be sorted, smallest to largest. The function returns 1 if successful, 0 if not successful (i.e. there is no space left in the array.
As well as function with these parameters:
int delete(struct node*LL, int number)
This routine deletes the node containing number from the Linked List. This function returns 1 if the node is deleted, 0 if not (i.e. the node was not found in the list).
Here's my initialization function:
This is my add function:
This is my delete function:
struct node int data; int next; int valid; void add(struct node *list, int number) int MYNULL = -1; ew-node = (struct node if(new-node == MYNULL) *list)malloc ( sizeof(node)); return NULL; ew node-> list . data = number; ew_node-) list . next node->list, next ; ode->next = new node; return listStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started