Question: C++: Please answer correctly, I will upvote! 1) Modify the following code as needed to run in your environment. As well as the values for

C++: Please answer correctly, I will upvote!

1) Modify the following code as needed to run in your environment. As well as the values for M and N given in the code, test all combinations of values of M = 2, 3, 5, 10 and N = 103, 104, 105, 106.

2) Explain the node class and the main function through comments in the code file and a written summary that includes your displayed test results.

3) Create the following functions for processing nodes: remove(), insert(), next(), annd item(). Test them independently of the processing done in the code below. Be sure to document your code, summarize the way you implemented them, and how you tested the functions.

4) Replace any operations in the code below with equivalent functions that you implemented in problem 3 above, where appropriate. Document your replacements and give proof in your summary that you get the same results as with the original code.

------------------------------------------

#include

usingnamespacestd; classnode { public: intitem; node* next; node(intx, node* t) { item = x; next = t; } }; typedefnode *link; intmain() { inti, N = 9, M = 5; link t = newnode(1, 0); t->next = t; link x = t; for(i = 2; i <= N; i++) x = (x->next = newnode(i, t)); while(x != x->next) { for(i = 1; i < M; i++) x = x->next; x->next = x->next->next; } cout << x->item << endl; }

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!