Answered step by step
Verified Expert Solution
Link Copied!

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.

  1. define a doubly linked list node structure NODE to hold char data.
  2. NODE *new_node(char data); this creates a new node using malloc().
  3. void display_forward(NODE *start); this displays char data from start to end.
  4. void display_backward(NODE *end); this displays char data from end to start.
  5. void insert_start(NODE **startp, node **endp, node *new_np); this inserts a new node at the start the of doubly linked list.
  6. void insert_end(NODE **startp, node **endp, node *new_np); this inserts a new node at the end of the doubly linked list.
  7. void delete_start(NODE **startp, node **endp); this deletes the first node of the doubly linked list.
  8. void delete_end(NODE **startp, node **endp); this deletes the last node of the doubly linked list.
  9. 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

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_2

Step: 3

blur-text-image_3

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

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

1 . Distinguish between Stress & Strain.

Answered: 1 week ago