Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with this question please below is what i have it is in C programming. define a doubly linked list node structure NODE
I need help with this question please below is what i have it is in C programming.
- define a doubly linked list node structure NODE to hold char data.
- NODE *new_node(char data); this creates a new node using malloc().
- void display_forward(NODE *start); this displays char data from start to end.
- void display_backward(NODE *end); this displays char data from end to start.
- void insert_start(NODE **startp, node **endp, node *new_np); this inserts a new node at the start the of doubly linked list.
- void insert_end(NODE **startp, node **endp, node *new_np); this inserts a new node at the end of the doubly linked list.
- void delete_start(NODE **startp, node **endp); this deletes the first node of the doubly linked list.
- void delete_end(NODE **startp, node **endp); this deletes the last node of the doubly linked list.
- void clean(NODE **startp, NODE **endp); this cleans the doubly linked list.
dllist.h
#ifndef DLLIST #define DLLIST #include#include typedef struct node { char data; struct node *prev; struct node *next; } NODE; NODE *new_node(char data); void display_forward(NODE *start); void display_backward(NODE *end); void insert_start(NODE **startp, NODE **endp, NODE *new_np); void insert_end(NODE **startp, NODE **endp, NODE *new_np); void delete_start(NODE **startp, NODE **endp); void delete_end(NODE **startp, NODE **endp); void clean(NODE **startp, NODE **endp); #endif
dllist.c
#include "dllist.h" NODE *new_node(char data) { // your code } void display_forward(NODE *np) { // your code } void display_backward(NODE *np) { // your code } void insert_start(NODE **startp, NODE **endp, NODE *new_np) { // your code } void insert_end(NODE **startp, NODE **endp, NODE *new_np) { // your code } void delete_start(NODE **startp, NODE **endp) { // your code } void delete_end(NODE **startp, NODE **endp) { // your code } void clean(NODE **startp, NODE **endp) { // your code }
#include "dllist.h" int main(int argc, char* args[]) { NODE *start = NULL, *end = NULL; int i=0; for (i = 0; i<10; i++) { insert_start(&start, &end, new_node('0'+i)); } display_forward(start); printf(" "); display_backward(end); delete_start(&start, &end); delete_end(&start, &end); printf(" "); display_forward(start); clean(&start, &end); for (i = 0; i<10; i++) { insert_end(&start, &end, new_node('a'+i)); } printf(" "); display_forward(start); clean(&start, &end); return 0; }
Step 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