Solving T(n) = O(n lg n) using substitution method?

  • MHB
  • Thread starter evinda
  • Start date
In summary, the conversation discusses solving a recursive relation and proving its solution to be $O(n \lg n)$. The person first considers using an inequality to solve the relation, but they encounter a contradiction. Then, they consider using the substitution method, but they are unsure if they are allowed to assume what they need to show. Finally, they mention the possibility of using the Master theorem or the Akra-Bazzi method, but they are not familiar with these methods and are supposed to solve the problem using the substitution method.
  • #1
evinda
Gold Member
MHB
3,836
0
Hello! :-)

I am looking at the following exercise:
Show that the solution of the recursive relation $T(n)=2T( \lfloor \frac{n}{2} \rfloor +17)+n$ is $O(n \lg{n})$.

So,we suppose that $T(n)=O(n \lg n)$.

In order the recursive relation to be well-defined,I thought to use the inequality $\lfloor x \rfloor \geq x-1$ and I found:

$$ \lfloor \frac{n}{2} \rfloor+17 \leq n \Rightarrow n \geq \lfloor \frac{n}{2} \rfloor +17> \frac{n}{2}-1+17 \Rightarrow n>\frac{n}{2}+16 \Rightarrow n\geq 33$$

$$\text{ So, } n_0=33$$

As $T(n)=O(n \lg n)$,we suppose that $\exists c,b>0 \text{ such that } \forall n \geq 33 : T(n) \leq c(n-b) \lg n$We suppose that the relation stands also for $\lfloor \frac{n}{2} \rfloor+17$,then: $T(\lfloor{\frac{n}{2}} \rfloor+17) \leq c(\lfloor \frac{n}{2} \rfloor +17-b) \lg (\lfloor \frac{n}{2} \rfloor+17)$

$$T(n)\leq 2c(\lfloor \frac{n}{2} \rfloor+17-b) \lg ( \lfloor \frac{n}{2} \rfloor +17)+n \leq 2c (\frac{n}{2}+17-b) \lg n+n = c(n-b+(34-b)) \lg n +n \leq c(n-b) \lg n +n,\text{ if } 34 \leq b$$

We also know that it must be $ T(n)\geq 0 \Rightarrow n \geq b \Rightarrow b\leq n, \forall n \geq n_0 \Rightarrow b\leq n_0 \Rightarrow b \leq 33$

So,we have a contradiction..Also,even if it was not a contadiction,we couldn't do it in this way,because: $c(n-b) \lg n +n \geq c(n-b) \lg n$

But..how can we show it then? (Thinking)
 
Last edited:
Technology news on Phys.org
  • #2
evinda said:
I am looking at the following exercise:
Show that the solution of the recursive relation $T(n)=2T( \lfloor \frac{n}{2} \rfloor +17)+n$ is $O(n \lg{n})$.

So,we suppose that $T(n)=O(n \lg n)$.
Do you always assume what you need to show?

evinda said:
As $T(n)=O(n \lg n)$,we suppose that $\exists c,b>0 \text{ such that } \forall n \geq 33 : T(n) \leq c(n-b) \lg n$
Why not $T(n) \leq cn\lg n$?

This problem would be covered by the master theorem (case 2) if it were not for $+17$. It is covered by the Akra–Bazzi method, which is a generalization of the master theorem. In the notations of the Wiki page, $g(x)=x$, $k=1$, $a=2$, $b=1/2$ and $h(x)=17+\lfloor n/2\rfloor-n/2$. However, this theorem is more advanced and may not be covered in some courses dealing with recurrence relations.

What is the context of this problem? Where in the course or book are you? What methods are you supposed to solve it?
 
  • #3
Evgeny.Makarov said:
Do you always assume what you need to show?

I saw at the solution of a similar exercise that they did it like that.. So is it wrong? (Thinking)(Worried)

Evgeny.Makarov said:
Why not $T(n) \leq cn\lg n$?

I have also tried it,supposing $T(n) \leq cn\lg n$,then I supposed that the relation also stands for $\lfloor \frac{n}{2} \rfloor +17: T(\frac{n}{2} \rfloor +17) \leq c( \lfloor \frac{n}{2} \rfloor +17) \lg (\lfloor \frac{n}{2} \rfloor+17)$

So:

$$T(n) \leq 2c(\lfloor \frac{n}{2} \rfloor+17) \lg (\lfloor \frac{n}{2} \rfloor+17)+n \leq 2c(\lfloor \frac{n}{2} \rfloor+17) \lg n+n \leq 2c(\frac{n}{2}+17) \lg n+n \leq c(n+34) \lg n +n$$
Evgeny.Makarov said:
This problem would be covered by the master theorem (case 2) if it were not for $+17$. It is covered by the Akra–Bazzi method, which is a generalization of the master theorem. In the notations of the Wiki page, $g(x)=x$, $k=1$, $a=2$, $b=1/2$ and $h(x)=17+\lfloor n/2\rfloor-n/2$. However, this theorem is more advanced and may not be covered in some courses dealing with recurrence relations.

What is the context of this problem? Where in the course or book are you? What methods are you supposed to solve it?

I haven't seen the Master theorem yet..I am supposed to solve it,using the substitution method.. (Worried)
 

Related to Solving T(n) = O(n lg n) using substitution method?

1. How do you show that T(n) = O(n lgn)?

In order to show that T(n) = O(n lgn), you need to prove that there exists a constant c and a value n0 such that for all values of n greater than n0, T(n) is less than or equal to c*n*log(n). This can be done by using mathematical induction or through other methods of analysis.

2. What is the significance of T(n) = O(n lgn)?

T(n) = O(n lgn) is a notation used in computer science to describe the time complexity of an algorithm. It represents an upper bound on the time taken by the algorithm to execute, meaning that the actual time taken may be less than or equal to the time represented by the notation.

3. Can you provide an example of an algorithm with T(n) = O(n lgn)?

One example of an algorithm with T(n) = O(n lgn) is merge sort. This algorithm has a time complexity of O(n lgn) as it divides the input array into two halves, sorts them separately, and then merges them together in linear time. This results in a time complexity of n*log(n).

4. What is the difference between T(n) = O(n lgn) and T(n) = Θ(n lgn)?

While both T(n) = O(n lgn) and T(n) = Θ(n lgn) represent the same upper bound on the time complexity of an algorithm, they have different meanings. T(n) = O(n lgn) represents the upper bound on the worst-case time complexity, while T(n) = Θ(n lgn) represents the exact time complexity of the algorithm in all cases.

5. How does the value of c affect the time complexity represented by T(n) = O(n lgn)?

The value of c in T(n) = O(n lgn) represents the constant factor that multiplies n*log(n). This means that as the value of c increases, the upper bound on the time complexity also increases. However, the exact value of c does not affect the asymptotic behavior of the algorithm, as long as it is a constant value.

Similar threads

Replies
1
Views
1K
  • Programming and Computer Science
2
Replies
59
Views
8K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
Replies
9
Views
2K
Replies
1
Views
811
  • Programming and Computer Science
Replies
8
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
0
Views
1K
  • Programming and Computer Science
Replies
15
Views
3K
  • Programming and Computer Science
Replies
7
Views
2K
Back
Top