![]() |
VOOZH | about |
Given a number n, find the cube root of n.
Examples:
Input: n = 3 Output: Cubic Root is 1.442250 Input: n = 8 Output: Cubic Root is 2.000000
We can use binary search. First we define error e. Let us say 0.0000001 in our case. The main steps of our algorithm for calculating the cubic root of a number n are:
Below is the implementation of above idea.
Output:
Cubic root of 3.000000 is 1.442250
Time Complexity: O(logn)
Auxiliary Space: O(1)