Computer Science: Programming with a Purpose Week 7 Quiz Answer

Computer Science Programming with a Purpose Week 7 Quiz Answer

Computer Science: Programming with a Purpose Week 7 Quiz Answer


In this article i am gone to share Coursera Course Computer Science: Programming with a Purpose Week 7 | Performance Quiz Answer with you..


Performance


Question 1)
Which statements that characterize the doubling hypothesis? Mark all that apply.
  • A way to better understand the performance of a program
  • A way to avoid empirical tests of program performance
  • A way to determine the order of growth of the running time of a program
  • A way to improve the performance of a program
  • A way to avoid mathematical analysis of program performance



Question 2)
Which of the follovwing running times for a program consistent with the hypothesis that the order of growth of the program is quadratic (check all that apply)? Mark all that apply.

  • 1 second for N = 1,000,000, 2 seconds for N = 2,000,000, 8 seconds for N = 8,000,000
  • 1 second for N = 100,000, 4 seconds for N = 200,000, 16 seconds for N = 400,000
  • 1 second for N = 100,000, 8 seconds for N = 200,000, 64 seconds for N = 400,000
  • 1 second for N = 100,000, 4 seconds for N = 200,000, 32 seconds for N = 800,000
  • 1 second for N = 100,000, 4 seconds for N = 200,000, 64 seconds for N = 800,000




Question 3)
Which of the following is equivalent to saying a(n) - b(n) ? Mark all that apply.
  • The order of growth of a(n) is b(n)
  • The difference between a(n) and b(n) tends to 0 as n grows
  • The ratio of a(n) to b(n) tends to 0 as n grows
  • The difference between a(n) and b(n) is bounded by a constant
  • The ratio of a(n) to b(n) tends to 1 as n grows



Question 4)
The Java function below returns a string of length n whose characters are all x. What is the order of growth of its running time? (Recall that concatenating two strings in Java takes time proportional to the length of the resulting string.)

public static string method3(int n)
{
  if (n == 0) return "";
  if (n == 1) return "x";
  return method3 (n/2) + method3 (n - n/2);
}

  • linear
  • linearithmic
  • quadratic
  • cubic
  • exponential







Post a Comment

0 Comments