Back to questionsDSA Visualizers: 388 Coding Questions Word Search visualizer Learn Word Search with a step-by-step Recursion & Backtracking visualizer, JavaScript source code and a worked example. Practice constraint search.
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 / 7 Execution step
Prediction modePanel width Reference example · JavaScript
Inspect reference input {
"a": [
[
"A",
"B",
"C"
],
[
"S",
"F",
"C"
],
[
"A",
"D",
"E"
]
],
"w": "ABCCED"
} Code Visuals
JavaScript reference implementation · highlighted trace statement
1 const solve = ({
2 a,w
3 },s)=>{
4 let seen=new Set;
5 function f(i,j,k){
6 if (k===w.length)return true ;
7 if (a[i]?.[j]!==w[k]||seen.has(i+","+j))return false ;
8 let p=i+","+j;
9 seen.add(p);
10 s("Match letter "+w[k],{
11 Grid:a,Path:[...seen]
12 });
13 let yes=[[1 ,0 ],[-1 ,0 ],[0 ,1 ],[0 ,-1 ]].some(([x,y])=>f(i+x,j+y,k+1 ));
14 seen.delete(p);
15 return yes
16 }
17 return a.some((r,i)=>r.some((_,j)=>f(i,j,0 )))
18 };
Execution canvas Active ChangedSTEP 1 Match letter A Inspect the highlighted code and the state below. Click individual cells or nodes to see their values.
Worked example and algorithm walkthrough Topic: Recursion & Backtracking · Constraint search
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 {
"a": [
[
"A",
"B",
"C"
],
[
"S",
"F",
"C"
],
[
"A",
"D",
"E"
]
],
"w": "ABCCED"
} Execution steps Match letter A Match letter B Match letter C Match letter E Match letter D Computed output true JavaScript reference implementation const solve = ({
a,w
},s)=>{
let seen=new Set;
function f(i,j,k){
if(k===w.length)return true;
if(a[i]?.[j]!==w[k]||seen.has(i+","+j))return false;
let p=i+","+j;
seen.add(p);
s("Match letter "+w[k],{
Grid:a,Path:[...seen]
});
let yes=[[1,0],[-1,0],[0,1],[0,-1]].some(([x,y])=>f(i+x,j+y,k+1));
seen.delete(p);
return yes
}
return a.some((r,i)=>r.some((_,j)=>f(i,j,0)))
};Continue learning Practice related DSA questions in the same topic.