algorithm,runtime,complexity-theory,master-theorem

Here is code snippet to find the divisors factors of all numbers from 2 to N done in O(N^3/2). for(int i=2;i<=N;i++) { for(j=2;j*j<=i;j++) { if(i%j==0) { printf("another non-trivial divisor pair for %d is %d,%d",i,j,i/j); } } } Outer loop is O(N) and inner is O(N^1/2)....

algorithm,math,big-o,recurrence,master-theorem

One useful fact is that for any ε > 0, we know that log n = O(nε). We also know that log n = Ω(1) Let's see if this tells us anything. We know that your recurrence is bounded from above by this one for any ε > 0: S(n)...

data-structures,recurrence,master-theorem

This looks more like the Akra-Bazzi theorem: http://en.wikipedia.org/wiki/Akra%E2%80%93Bazzi_method#The_formula with k=1, h=0, g(n)=log n, a=(2)^{1/2}, b=1/2. In that case, p=1/2 and you need to evaluate the integral \int_1^x log(u)/u^{3/2} du. You can use integration by parts, or a symbolic integrator. Wolfram Alpha tells me the indefinite integral is -2(log u +...

algorithm,divide-and-conquer,master-theorem

For the recurrence T(n) = 4T(n/2) + n^2 * log n None of the three cases applies because there does not exist an e such that log n = Ω(n^e) or log n = O(n^(-e))...

This is a case 1 formula, since: log_b(a) = 1 f(n) = 3, 3 is in O(1)=O(n^0) -> c = 0 < 1 = log_b(a) So, the formula is in Theta(n^(log_b(a)) = Theta(n) This is NOT case 2, because case 2 requires f(n)=3 to be in Theta(n^(log_b(a)) = Theta(n), but...

recursion,mergesort,master-theorem

The recursion tree for the given recursion will look like this: Size Cost n n / \ 2n/5 3n/5 n / \ / \ 4n/25 6n/25 6n/25 9n/25 n and so on till size of input becomes 1 The longes simple path from root to a leaf would be n->...