Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

This is my add function:

image text in transcribed

This is my delete function:

image text in transcribed

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 list

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions