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?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
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