FAQ Database Discussion Community


Resolution easy recurrence equation

time-complexity,recurrence-relation
I have to find the recurrence equation of following function. public static boolean f(int[] a) { return fr(a, 0); } private static boolean fr(int[] a, int i) { int n = a.length; if(i >= n-1) return true; else if(a[i] > a[i+1]) return false; else return fr(a, i+1); } I think...

Is my recurrence relation right for subset sum?

dynamic-programming,recurrence-relation,subset-sum
Is this recurrence relation correct for the subset sum problem? Statement: Print Yes or No depending on whether there is a subset of the given array a[ ] which sums up to a given number n. dp[i][j] = true, if 0 to j elements in array sum up to i...

coin change recurrence solution

dynamic-programming,recurrence,recurrence-relation
Given a value N, if we want to make change for N cents, and we have infinite supply of each of S = { S1, S2, .. , Sm} valued coins, how many ways can we make the change? The order of coins doesn’t matter.There is additional restriction though: you...

What is the Difference between T(n) (reccurence relations), Big O and Big Theta

algorithm,big-o,analysis,recurrence-relation,big-theta
I am wondering about this for my Algorithm class. It seems to be unclear what the difference is between BigO, Big Theta, and Recurrence relations (T(n)) For example: T(n) = 4T(n/3) + O(1)

partition recurrence relation understanding

algorithm,recurrence,recurrence-relation
Determine if there is a subset of S that sums to floor(N/2) floor. Given S = {3,1,1,2,2,1}, a valid solution to the partition problem is the two sets S1 = {1,1,1,2} and S2 = {2,3}. Let: p(i, j) be True if a subset of {x1, ..., xj} sums to i...

Maximum number of distinct inversions in an array

sorting,recurrence-relation
Given an array A of n integers, we say that a pair of indices i<j∈[n] is an inversion in A if A[i]>A[j]. What is the maximum number of distinct inversions that A can have? Is it a) n - 1 b) n c) n(n−1)/2 d) n^2 e) n(n−1)(2n−1)/6 ...

Solving recurrence equation without the Master's Theorem

big-o,recurrence-relation
So, on a previous exam, I was asked to solve the following recurrence equation without using the Master Theorem: T(n)= 9T(n/3) + n^2 Unfortunately, I couldn't figure it out on the exam, so I used solved it using the Master's Theorem just so I could know the answer (but, of...

Recurrence relation of an algorithm

c++,algorithm,recursion,recurrence-relation
void doSomething(int *a, int left, int right){ if (left == right){ for (int j = 0; i < right; ++j) cout << a[j]; cout << endl; return; } for (int i = left; i < right; ++i){ std::swap(a[left], a[i]); doSomething(a, left + 1, right); std::swap(a[left], a[i]); } } "Derive the...

Solving a complex recurrence relation for the Traveling Salesman

algorithm,math,time-complexity,computer-science,recurrence-relation
I need to solve the exact time complexity for the brute force version of the Traveling Salesman using a recurrence relation. I've worked out the recurrence relation to be as follows: T(n)=T(n-1)*(n-1)+1 But I'm having trouble reducing that that to a closed form of the function, and thus get the...

Proving a tricky Recurrence Relation for the k + 1 case

math,recurrence,recurrence-relation
I am absolutely stumped on this one. T(n) = { 3, if n = 2 || T(n - 1) + (n/4), if n > 2 Prove by induction that T(n) = (n^2 + n + 18) / 8 [V n >= 2] I know how to execute a proof by...

Median of median algorithm recurrence relation

sorting,recursion,recurrence-relation,quickselect,median-of-medians
I know that the linear select (median of medians algorithm) recurrence equation is as follows: T(n) <= an + T(n/5) + T(7n/10) But where do these terms come from? I've been trying to understand, but I'm extremely confused. Can anyone please shed some light?...