In the book CLRS, in page 69 it's said nC2 is Θ(n^2) in the unit divide and conquer(U - 4). Can anyone expalin how this result is true?
Asked
Active
Viewed 1,742 times
1
-
< CONSTn^2 for all n>0, CONST=1/2 - which means O(n^2) by definition – amit Jun 20 '14 at 11:11
-
You can see it that way: you choose your first element (O(n) choices possible) then your second (O(n) again) so you have a O(n²) upper bound. – user189 Jun 20 '14 at 11:11
-
@amit-he is asking about theta notation! – Am_I_Helpful Jun 20 '14 at 11:13
-
@user189-he is asking about theta notation! – Am_I_Helpful Jun 20 '14 at 11:14
-
@shekharsuman It will be pretty much identical to show the same thing for big Omega, and from there it is big theta by definition. – amit Jun 20 '14 at 11:17
-
Possible duplicate of [The complexity of n choose 2 is in Theta (n^2)?](https://stackoverflow.com/questions/19415988/the-complexity-of-n-choose-2-is-in-theta-n2) – smit shah Oct 11 '19 at 05:09
1 Answers
6
nC2 = n*(n-1)/2 = (n^2-n)/2;
Hint :
(n^2-n)/2
will be greater than c1*(n^2)
for some constants like c1 < 1/4
and for value of n = 2
. Similarly it will be smaller than c2*n^2
for values of c2 = 1
and n = 2
. So, here is it's a sandwich like situation. Similarly, it'll be sandwiched for other values of n and constants c. Hence, nC2 is Θ(n^2)
.

Community
- 1
- 1

Am_I_Helpful
- 18,735
- 7
- 49
- 73