recursion - Java Recursive efficiency analysis -


i need creating efficiency analysis method 1 below. need come with:

  1. factors influence runtime
  2. what being counted(comparisons, operations)?
  3. best/worst case
  4. big o notation

here's have far:

  1. array length
  2. math operations
  3. worst case , best case same, method run whole array, regardless of contents
  4. no idea

let me know think.

thanks

double sum(double[] array) {     return recursivesum(array, 0, array.length - 1); }  double recursivesum(double[] array, int lo, int hi) {     if (lo == hi) {         return array[lo];     }      int mid = (lo + hi) / 2;     double leftsum = recursivesum(array, lo, mid);     double rightsum = recursivesum(array, mid+1, hi);     return leftsum + rightsum; } 

my answer:

  1. array length
  2. no idea
  3. worst case , best case same, method run whole array, regardless of contents
  4. o(nlogn) (f(n)=2*f(n/2) -> f(n)=o(nlogn))

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -