Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given this .h file and the two written functions below. Write the functions below in C. Thank You Very Much. #ifndef LIST H #define LIST-H-

image text in transcribedGiven this .h file and the two written functions below.

image text in transcribed

Write the functions below in C.

image text in transcribed

Thank You Very Much.

#ifndef LIST H #define LIST-H- #include #include struct ListNode long value; struct ListNode *prev; struct ListNode *next truct ListNode list_prepend (struct ListNode list, long value) struct ListNode list_append (struct ListNode list, long value) struct ListNode list_remove (struct ListNode list, struct ListNode *node) Struct ListNode list_remove_value (struct ListNode list, long value) truct ListNode list_find (struct ListNode list, long value) ListNode +list_insert (struct ListNode list, struct ListNode after, struct ListNode node) int list_count (struct ListNode list, long value) bool list_validate (struct ListNode 1ist) fendif /LIST_ H 1 //PREPEND 2. struct ListNode 11st-prepend(struct ListNode list, long value){ struct ListNode, new-node new-node-value = value; new-node-next list; new_node->prev NULL; if (list != NULL) (struct ListNode*)malloc(sizeof(struct ListNode)); = 4 5 6 7 8 9 10 list->prev new_node; return new_node; 12 //APPEND 13 struct ListNode list_append ((struct ListNode list, long value) struct ListNode, new-node = (struct struct ListNode last-list; new_node->value value; new-node->next = NULL; if (list == NULL) { ListNode*)malloc(sizeof(struct ListNode)); 14 15 16 17 18 19 20 21 new-node-prev = NULL; list = new node; return list; 23 24 25 26 27 28 while (last->nextNULL) last last->next; last->next new_node; new_node-prev last;l return 1ist; Returns the new list head. / struct ListNode list_remove (struct ListNode list, struct ListNode node) return NULL; Remove the first node containing the specified value from the specified list, and free the removed node. If no node matches,the list will remain unchanged. Returns the new list head. / struct ListNode list_remove_value (struct ListNode list, long value) return NULL Find the first occurrence of value in the specified list, and return the node containing that value, if it exists. The list will not be * modified. Returns the found node if it exists, or NULL otherwise. / struct ListNode list_find (struct ListNode list, long value) return NULL #ifndef LIST H #define LIST-H- #include #include struct ListNode long value; struct ListNode *prev; struct ListNode *next truct ListNode list_prepend (struct ListNode list, long value) struct ListNode list_append (struct ListNode list, long value) struct ListNode list_remove (struct ListNode list, struct ListNode *node) Struct ListNode list_remove_value (struct ListNode list, long value) truct ListNode list_find (struct ListNode list, long value) ListNode +list_insert (struct ListNode list, struct ListNode after, struct ListNode node) int list_count (struct ListNode list, long value) bool list_validate (struct ListNode 1ist) fendif /LIST_ H 1 //PREPEND 2. struct ListNode 11st-prepend(struct ListNode list, long value){ struct ListNode, new-node new-node-value = value; new-node-next list; new_node->prev NULL; if (list != NULL) (struct ListNode*)malloc(sizeof(struct ListNode)); = 4 5 6 7 8 9 10 list->prev new_node; return new_node; 12 //APPEND 13 struct ListNode list_append ((struct ListNode list, long value) struct ListNode, new-node = (struct struct ListNode last-list; new_node->value value; new-node->next = NULL; if (list == NULL) { ListNode*)malloc(sizeof(struct ListNode)); 14 15 16 17 18 19 20 21 new-node-prev = NULL; list = new node; return list; 23 24 25 26 27 28 while (last->nextNULL) last last->next; last->next new_node; new_node-prev last;l return 1ist; Returns the new list head. / struct ListNode list_remove (struct ListNode list, struct ListNode node) return NULL; Remove the first node containing the specified value from the specified list, and free the removed node. If no node matches,the list will remain unchanged. Returns the new list head. / struct ListNode list_remove_value (struct ListNode list, long value) return NULL Find the first occurrence of value in the specified list, and return the node containing that value, if it exists. The list will not be * modified. Returns the found node if it exists, or NULL otherwise. / struct ListNode list_find (struct ListNode list, long value) return NULL

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions