I am studying discrete math for tomorrow's exam and got stuck in the below question. I tried to google it and couldn't find anything usefull.
Prove the following sum is theta(n^2) (we have to find O(n^2) and omega (n^2))
1) $P(n)= 1+2+3+4+\cdots +n$
2) $P(n) =n+(n+1)+(n+2)+\cdots +2n$
Note: you cannot use any formula you have to do it my algebraic manipulation.
This might be simple but I am not getting any clue right now and I dont have solution of it.
1) Notice that $P(n) = \sum_{i=1}^{n} i = \frac{n(n-1)}{2} \leq n^{2} \implies P(n) \in O(n^{2})$.
Or perhaps you would prefer: $P(n) = \sum_{i=1}^{n} i \leq \sum_{i=1}^{n} n = n^{2}$. This gives you $P(n) \in O(n^{2})$.
Then you can show $n^{2} \leq 3P(n)$ to get $P(n) \in \Omega(n^{2})$.
2) Use the same trick. $P(n) = \sum_{i=0}^{n} (n + i) \leq \sum_{i=0}^{n} 2n = 2 \sum_{i=0}^{n} n = 2n^{2}$. Then just apply the techniques from part (1).