Course Solutions Uncategorized (Solved) : C Function Deletes Nodes Linked List Even Values Program Actually Free Nodes Bypass Examp Q30073784 . . . .

(Solved) : C Function Deletes Nodes Linked List Even Values Program Actually Free Nodes Bypass Examp Q30073784 . . . .

 

C function that deletes all nodes from a linked list with evenvalues?

The program has to actually free the nodes not just bypassthem.

For example: the input- {2, 2, 2, 1, 2, 2, 7, 9} should return1, 7, 9.

#include <stdio.h>

#include <stdlib.h>

typedef struct node

{

int data;

struct node *next;

} node;

node *create_node(int data)

{

node *ptr = malloc(sizeof(node));

  

if (ptr == NULL)

{

fprintf(stderr, “Error: Out of memory in create_node()n”);

exit(1);

}

  

ptr->data = data;

ptr->next = NULL;

  

return ptr;

}

node *tail_insert(node *head, int data)

{

node *temp;

if (head == NULL)

return create_node(data);

for (temp = head; temp->next != NULL; temp =temp->next)

;

temp->next = create_node(data);

return head;

}

void print_list(node *head)

{

node *temp;

  

if (head == NULL)

{

printf(“(empty list)n”);

return;

}

  

for (temp = head; temp != NULL; temp = temp->next)

printf(“%d%c”,

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post