Question: Need to write the following functions in dlist.cpp , add function prototypes for them to dlist.h and invoke the functions in main.cpp . You should

Need to write the following functions in dlist.cpp, add function prototypes for them to dlist.h and invoke the functions in main.cpp. You should label the output of your test, such as the list after removal: etc.

int countEven(node * head)

recursively compute and return the number of nodes that contains even number in the doubly linked list.

int removeEven(node *& head)

recursively remove all the nodes that contain even number in the doubly linked list and return the number of nodes removed

main.cpp

#include "dlist.h" using namespace std;

int main() { node * head = NULL; build(head); display(head);

//PLEASE PUT YOUR CODE HERE to call the function assigned

display(head); destroy(head); return 0; }

dlist.h

#ifndef DLIST_H #define DLIST_H //doubly linked list #include #include #include #include

struct node { int data; node * previous; node * next; };

/* These functions are already written and can be called to test out your code */ void build(node * & head); //supplied void display(node * head); //supplied void destroy(node * &head); //supplied

/* *****************YOUR TURN! ******************************** */ /* place your prototype here */ #endif

dlist.cpp

#include "dlist.h"

//put the implmenetation of the required functions here

Please try to use recursion for the two functions.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!