Back to questionsDSA Visualizers: 388 Coding Questions Nth Root of an Integer visualizer Learn Nth Root of an Integer with a step-by-step Binary Search visualizer, JavaScript source code and a worked example. Practice search on answer.
INTERACTIVE EXECUTION STUDIOLEARN BY DOING Predict. Execute. Understand. Follow the source code, inspect live state changes, and predict the next operation before revealing it.
1 / 4 Execution step
Prediction modePanel width Reference example · JavaScript
Inspect reference input {
"n": 3,
"m": 27
} Code Visuals
JavaScript reference implementation · highlighted trace statement
1 const solve = ({
2 n,m
3 },s)=>{
4 let l=1 ,r=m;
5 while (l<=r){
6 let x=(l+r)>>1 ,v=x**n;
7 s("Compare power",{
8 Bounds:[l,x,r],Power:[v],Target:[m]
9 });
10 if (v===m)return x;
11 if (v<m)l=x+1 ;
12 else r=x-1
13 }
14 return -1
15 };
Execution canvas Active ChangedSTEP 1 Compare power Inspect the highlighted code and the state below. Click individual cells or nodes to see their values.
Worked example and algorithm walkthrough Topic: Binary Search · Search on answer
Follow the computed execution on the reference input. Advance one step at a time, inspect the changing values and compare your prediction with the final output.
Example input {
"n": 3,
"m": 27
} Execution steps Compare power Computed output 3 JavaScript reference implementation const solve = ({
n,m
},s)=>{
let l=1,r=m;
while(l<=r){
let x=(l+r)>>1,v=x**n;
s("Compare power",{
Bounds:[l,x,r],Power:[v],Target:[m]
});
if(v===m)return x;
if(v<m)l=x+1;
else r=x-1
}
return -1
};Continue learning Practice related DSA questions in the same topic.