### Sqrt(n), give the best, average, worst case runtimes, then big-O runtime

Ok, I need to figure out the best case, average case, worst case runtimes then give the big O runtime. I understand that best case would be if someone entered a low number. I know how to convert efficiencies to big O. But I am so confused on how to get these efficiencies, such as f(n) = 1 or f(n) = n / 2 for the square root program below. Can anyone help?

 123456789101112131415 #include #include using namespace std; int main() { float num, root; cout << "Please enter a number" << endl; //Get number from user cin >> num; //save number root = sqrt(num); // get square root cout << "The square root of " << num << " is " << root; //print root to screen }
It depends on how sqrt is implemented.
Simple explanation of Big-O, plus links to understand better
http://www.cplusplus.com/faq/sequences/sequencing/sort-algorithms/#Big-O

Remember:

constant means that the speed of the algorithm is the same no matter what the input,

linear means that the speed of the algorithm is directly proportional to the size of the input (a linear function),