Show that $S(m)=\Theta(m^2)$ with Recurrence Relation

In summary, the conversation discusses proving that the function $S(m)$ is equivalent to $\Theta(m^2)$ and finding the exact solution of the recurrence relation. The speaker presents their approach, asking for confirmation on its correctness. The other person suggests writing the equation in a different form and provides a solution, concluding that $S(m)=\mathcal{O}(n^2)$. The speaker then asks for feedback on their method and clarification on finding the exact solution.
  • #1
evinda
Gold Member
MHB
3,836
0
Hello! (Smile)

Let $S(m)=S(m-1)+m$.
I want to show that $S(m)=\Theta(m^2)$.

That's what I have tried:

We suppose a positive integer $m>0$. We suppose that $S(m-1)=\Theta((m-1)^2)$, so it holds that $\exists c_1, c_2>0$ such that :
$$c_1 (m-1)^2 \leq S(m-1) \leq c_2(m-1)^2$$

We will show that $c_1 m^2 \leq S(m) \leq c_2 m^2$.

$$S(m)=S(m-1)+m \leq c_2(m-1)^2+m=c_2 m^2-2c_2 m +c_2+m=c_2m^2-(2c_2m-c_2-m) \leq c_2 m^2, \text{ if } 2c_2m-c_2-m \geq 0 \Rightarrow c_2(2m-1) \geq m \Rightarrow c_2 \geq \frac{m}{2m-1} \to \frac{1}{2} \Rightarrow c_2 \geq \frac{1}{2}$$

So, we have that $S(m)=O(m^2)$.

$$S(m)=S(m-1)+m \geq c_1(m-1)^2+m=c_1 m^2-2c_1 m +c_1+m=c_1m^2-(2c_1m-c_1-m) \geq c_1 m^2, \text{ if } 2c_1m-c_1-m \leq 0 \Rightarrow c_1(2m-1) \geq m \Rightarrow c_1 \geq \frac{m}{2m-1} \to \frac{1}{2} \Rightarrow c_1 \geq \frac{1}{2}$$

So, we have that $S(m)=\Omega(m^2)$.

Therefore, $S(m)=\Theta(m^2)$.

Could you tell me if it is right or if I have done something wrong? (Thinking)

Also, can we find from the above the exact solution of the recurrence relation, or do we have to do it in an other way, like using the substitution method? If so, how can we know when the recursion ends, without having an initial condition? :confused:
 
Physics news on Phys.org
  • #2
evinda said:
Hello! (Smile)

Let $S(m)=S(m-1)+m$.
I want to show that $S(m)=\Theta(m^2)$.

That's what I have tried:

We suppose a positive integer $m>0$. We suppose that $S(m-1)=\Theta((m-1)^2)$, so it holds that $\exists c_1, c_2>0$ such that :
$$c_1 (m-1)^2 \leq S(m-1) \leq c_2(m-1)^2$$

We will show that $c_1 m^2 \leq S(m) \leq c_2 m^2$.

$$S(m)=S(m-1)+m \leq c_2(m-1)^2+m=c_2 m^2-2c_2 m +c_2+m=c_2m^2-(2c_2m-c_2-m) \leq c_2 m^2, \text{ if } 2c_2m-c_2-m \geq 0 \Rightarrow c_2(2m-1) \geq m \Rightarrow c_2 \geq \frac{m}{2m-1} \to \frac{1}{2} \Rightarrow c_2 \geq \frac{1}{2}$$

So, we have that $S(m)=O(m^2)$.

$$S(m)=S(m-1)+m \geq c_1(m-1)^2+m=c_1 m^2-2c_1 m +c_1+m=c_1m^2-(2c_1m-c_1-m) \geq c_1 m^2, \text{ if } 2c_1m-c_1-m \leq 0 \Rightarrow c_1(2m-1) \geq m \Rightarrow c_1 \geq \frac{m}{2m-1} \to \frac{1}{2} \Rightarrow c_1 \geq \frac{1}{2}$$

So, we have that $S(m)=\Omega(m^2)$.

Therefore, $S(m)=\Theta(m^2)$.

Could you tell me if it is right or if I have done something wrong? (Thinking)

Also, can we find from the above the exact solution of the recurrence relation, or do we have to do it in an other way, like using the substitution method? If so, how can we know when the recursion ends, without having an initial condition? :confused:

Writing the equation in slightly different form You have...

$\displaystyle s_{n+1} = s_{n} + n + 1\ (1)$

Setting $s_{0}$ the value of the $s_{n}$ for n=0, the solution of (1) is...

$\displaystyle s_{n} = s_{0} + \sum_{k=1}^{n} k = s_{0} + \frac{n\ (n+1)}{2}\ (2)$

... so that is $\displaystyle s_{n} = \mathcal{O} (n^{2})$...

Kind regards

$\chi$ $\sigma$
 
  • #3
chisigma said:
Writing the equation in slightly different form You have...

$\displaystyle s_{n+1} = s_{n} + n + 1\ (1)$

Setting $s_{0}$ the value of the $s_{n}$ for n=0, the solution of (1) is...

$\displaystyle s_{n} = s_{0} + \sum_{k=1}^{n} k = s_{0} + \frac{n\ (n+1)}{2}\ (2)$

... so that is $\displaystyle s_{n} = \mathcal{O} (n^{2})$...

Kind regards

$\chi$ $\sigma$

I see.. But is the way I showed that $S(m)=\Theta(m^2)$ also right?
Or have I done something wrong? :confused:
 

Related to Show that $S(m)=\Theta(m^2)$ with Recurrence Relation

What is a recurrence relation?

A recurrence relation is a mathematical equation that defines a sequence of numbers, where each term is defined in terms of previous terms. It is often used to describe the time complexity of algorithms.

How do you show that $S(m)=\Theta(m^2)$ with recurrence relation?

To show that $S(m)=\Theta(m^2)$ with recurrence relation, you need to prove that $S(m)=O(m^2)$ and $S(m)=\Omega(m^2)$. This can be done by using mathematical induction and showing that the recurrence relation follows the form of $S(m)=c \cdot m^2$ for some constant $c$.

What does $\Theta$ notation mean?

In the context of recurrence relations, $\Theta$ notation is used to describe the time complexity of an algorithm. It represents the average case time complexity and indicates that the algorithm's running time grows at the same rate as the function inside the notation, in this case $m^2$.

Can you provide an example of a recurrence relation that shows $S(m)=\Theta(m^2)$?

Yes, an example of a recurrence relation that shows $S(m)=\Theta(m^2)$ is $S(m)=2S(m-1)+m$, where $S(0)=1$. This can be solved using the substitution method and it can be shown that the solution follows the form of $S(m)=c \cdot m^2$, where $c=2$.

Why is it important to show the time complexity of an algorithm using recurrence relation?

Showing the time complexity of an algorithm using recurrence relation allows us to understand how the algorithm's running time grows as the input size increases. This can help in analyzing and comparing different algorithms to determine which one is more efficient in terms of time complexity.

Similar threads

  • Calculus and Beyond Homework Help
Replies
8
Views
337
  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
1K
  • Introductory Physics Homework Help
Replies
16
Views
449
  • Set Theory, Logic, Probability, Statistics
Replies
27
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
1K
  • Advanced Physics Homework Help
2
Replies
36
Views
2K
Replies
0
Views
442
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
911
  • Advanced Physics Homework Help
Replies
1
Views
609
Back
Top