|
|
|
|
|
by mining
1474 days ago
|
|
I would probably argue that either the first algorithm is incorrect (because searched can be larger than INT_MAX) or the complexity of the second algorithm is bound both by O(searched) (or sqrt(searched), if implemented with more vigour) and O(1) (because the value of 'searched' is bound by a constant). |
|
> to find the square root of an int:
so the value can't exceed INT_MAX :)
Overall, I know the two algorithms aren't perfect, but they're a simple minimal example to show the difference between complexity and runtime.