-4
for(i = 0; i < n; i++)
{
    j+=i;
} 

Assuming that Big O for the above code is O(2n), what will be Θ ( tight bound ) and Ω (lower bound) for the above code?

AbcAeffchen
  • 14,400
  • 15
  • 47
  • 66
a3.14_Infinity
  • 5,653
  • 7
  • 42
  • 66
  • 1
    Big O for the above code is `O(n)`. constants inside big O notation doesnt make a difference – Haris Oct 15 '14 at 10:03

2 Answers2

0
  1. O(2n) = 2⋅O(n) = O(n)
  2. Your algorithm is also in O(n2) or O(nn) or O(n*log(n)) etc. This is because O is an upper bound.
  3. It is in Θ(n) - theta (Θ) describes exactly how it works.
  4. Your algorithm is in Ω(n), but it is also in Ω(log(n)) or Ω(1), etc. This is because Omega (Ω) is for a lower bound.
AbcAeffchen
  • 14,400
  • 15
  • 47
  • 66
ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
0

Theta O (tight bound) is the actual amount of computation done that will be O(n) and Omega O (lower bound) is also O(n) i.e the minimum computation required