Question: In C++ using the code below, write: 1) An iterative function (that is one that uses a loop) to display the data in each node

In C++ using the code below, write:

1) An iterative function (that is one that uses a loop) to display the data in each node

2) A recursive function to display the data in each node

_____________________-

#include using namespace std; struct Node { Node* next; int data; }; Node * ADDNODE(Node * N, int d) { Node * B = new Node; N->next = B; B->data = d; B->next = NULL; return B; } int main() { //Node NNode; Node *X = new Node; Node *Y = new Node; Node *Z = new Node; X->data = 10; Y =ADDNODE(X, 20); Z =ADDNODE(Y, 30); cout<data<next->data<next->next->data<next->next->next->data<                                            

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!