Related Articles
Method of guessing and confirming
• Difficulty Level : Easy
• Last Updated : 20 Jan, 2021

The basic idea behind this method is to guess the answer, and then prove it correct by induction. This method can be used to solve any recurrence. If a solution is guessed and then try to verify our guess inductively, usually either the proof will succeed (in that case we are done), or the proof will fail (in that case the failure will help us refine our guess).

For example, consider the recurrence: . This doesn’t fit into the form required by the Master Theorems. Carefully observing the recurrence gives us the impression that it is similar to the divide and conquer method (diving the problem into √N subproblems each with size √N). As it can be seen that, the size of the subproblems at the first level of recursion is N. So, let us guess that , and then try to prove that the guess is correct.

Let’s start by trying to prove an upper bound:

The last inequality assumes only that . This is correct if N is sufficiently large and for any constant c, no matter how small.

From the above proof, we can see that our guess is correct for the upper bound. Now, let us prove the lower bound for this recurrence:

The last inequality assumes only that . This is incorrect if N is sufficiently large and for any constant k.

From the above proof, we can see that our guess is incorrect for the lower bound.

From the above discussion, it can be understood that is too big. But how about ? The lower bound is easy to prove directly:

Now, let us prove the upper bound for this Θ(N):

From the above induction, it can be understood that is too small and is too big. So, we need something bigger than N and smaller than ? How about ?

Proving upper bound for :

Proving lower bound for :

The last step doesn’t work. So, doesn’t work. What else is between N and ? How about ?

Proving upper bound for :

Proving lower bound for :

From the above proofs, it can see that and .
Technically, we’re still missing the base cases in both proofs, but we can be fairly confident at this point that .

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up