Question: Consider the following method definitions. Give the Big O void funcX(int n) { int j = 0; int k = n; while (j < k)
Consider the following method definitions. Give the Big O
void funcX(int n) { int j = 0; int k = n; while (j < k) { System.out.println("*"); j++; k--; } } void funcByThree(int n) { int k = 1; while (k < n) { System.out.println("*"); k = k*3; } } void funcY(int n) { for (int i = 0; i < n; i++) { for (int j = i; j > 0; j--) { funcX(n); } } } For each of the following statements, give the running time as a function of n using O( )- notation.
funcX(n);
funcY(n);
for(int k=0;k funcByThree(n); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
