Back to questionsDSA Visualizers: 388 Coding Questions Check Min Heap visualizer Learn Check Min Heap with a step-by-step Heaps visualizer, JavaScript source code and a worked example. Practice priority queues and top k.
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 / 5 Execution step
Prediction modePanel width Reference example · JavaScript
Inspect reference input [
1,
3,
2,
5,
4
] Code Visuals
JavaScript reference implementation · highlighted trace statement
1 const solve = (a,s)=>{
2 for (let i=1 ;
3 i<a.length;
4 i++){
5 let p=(i-1 )>>1 ;
6 s("Compare node to parent",{
7 Heap:a,Parent:[p],Child:[i]
8 },[p,i]);
9 if (a[p]>a[i])return false
10 }
11 return true
12 };
Execution canvas Active ChangedSTEP 1 Compare node to parent Inspect the highlighted code and the state below. Click individual cells or nodes to see their values.
Worked example and algorithm walkthrough Topic: Heaps · Priority queues and top K
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 [
1,
3,
2,
5,
4
] Execution steps Compare node to parent Computed output true JavaScript reference implementation const solve = (a,s)=>{
for(let i=1;
i<a.length;
i++){
let p=(i-1)>>1;
s("Compare node to parent",{
Heap:a,Parent:[p],Child:[i]
},[p,i]);
if(a[p]>a[i])return false
}
return true
};Continue learning Practice related DSA questions in the same topic.