for loop - complexity - bigtheta 3 for cycle -
i resolve problem don't have solution of kindly ask if can confirm if solution correct or not
int h=1; int cont = 0; (j = 2^n; j>1; j = j/2) { h = h * 2; (i =1; < j; = i*2) (k=2; k<h; k++) cont ++; }
i must find complexity of portion of code in bigtheta.
so, analyze third cycle grow in way
k -> linear until = h (h grow 2^w) - complexity log n.
about second, first cycles' limit 0 think complexity log n.
about first 2^n = 2^n-1 complexity n
the total complexity n * log n
you can proceed formally, step step, using sigma notation (i skipped steps, feel free ask more details if necessary):
Comments
Post a Comment