Calculate Time Complexity of following
(i)
Fππ (π = 1;π β€ π; π β = 2)
{Β
π₯ = π₯ + 1Β
}
(ii)
πππ (π = 1;π β€ π; π + +)
πππ (π = 1;π β€ π;π = π β 2)
{Β
β¦ .Β
β¦ .Β
}
(i)
Logarithmic time β O (log n)
The algorithm reduces the size of the input data in each step.
(ii)
Logarithmic time β O (log n)
Comments
Leave a comment