Question: QUESTION IS LONG, BUT IT SHOULD ONLY REQUIRE A SMALL AMOUNT OF CODE. WILL UPVOTE CORRECT ANSWER ASAP!! Modify the following code as needed to

QUESTION IS LONG, BUT IT SHOULD ONLY REQUIRE A SMALL AMOUNT OF CODE. WILL UPVOTE CORRECT ANSWER ASAP!!

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.

Explain the node class and the main function through comments in the code file and a written summary that includes your displayed test results. 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.

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 using namespace std; class node { public: int item; node* next; node(int x, node* t) { item = x; next = t; } }; typedef node *link; int main() { int i, N = 9, M = 5; link t = new node(1, 0); t->next = t; link x = t; for (i = 2; i <= N; i++) x = (x->next = new node(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!