why O(n^{2}) ?

The Gateway to Computer Science Excellence

+1 vote

The solution of the recurrence relation of $ T(n)=3T\left(floor \left(\frac{n}{4}\right)\right)+n$ is

- $O(n^{2})$
- $O(n/g n)$
- $O(n)$
- $O(l g n)$

+2 votes

T(n) = 3T(floor (n/4))+ n ~ 3T(n/4)+n

Apply Masters theorem

n ^ (log _{4} 3) < n

Hence T(n) = Θ(n)

If T(n) = Θ(n) then T(n) = O(n)

If T(n) = Θ(n) then T(n) = O(n ^{2} )

answer can be A and C

Correct me if i am wrong

0

f(n) = O(g(n)) means that if there exist positive constants c and n0 such that 0 ≤ f(n) ≤ c g(n) for all n> n0.

Simply speaking, for a value n, f(n) will be always less than or equal to g(n).

In our case f(n) =n; then g(n) can be any thing that has value greater than equal to f(n)

Example:

- n= O(n)
- n= O(n
^{2}) - n/1000= O(n
^{2}) - n= O(n
^{3}) - n
^{2}= O(n^{2}) - n
^{2}+n = O(n^{2})

52,345 questions

60,517 answers

201,937 comments

95,367 users