Question: (char d, int maxcount) { Node* ptr = first; bool chk=false; Node* temp; while (ptr != NULL) { if (ptr->data == d) { chk =
(char d, int maxcount) { Node* ptr = first; bool chk=false; Node* temp; while (ptr != NULL) { if (ptr->data == d) { chk = true; int count = 0; temp = ptr; while (ptr != NULL) { if (ptr->data == d) { count++; ptr = ptr->next; } else break; } if (count > maxcount) { while (count > maxcount) { del_after(temp); count--; } } else if (maxcount > count) { while (count < maxcount) { ins_after(temp,d); count++; } } // else } // outer if ptr = ptr->next; } // while return chk; } What is the exact time complexity (number of steps) of the function ? Provide complete justification. 2. Write down the asymptotic time complexity of function using Big-O notation. 3. Explain the best and worst cases for function using Big-O notation
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
