split into 3 steps

This commit is contained in:
Jidong Xiao
2025-03-26 11:41:05 -04:00
committed by JamesFlare
parent 981bb8394b
commit 73b283c87f
2 changed files with 21 additions and 11 deletions

View File

@@ -365,16 +365,26 @@ function nextstep() {
stage.find('#nullptr').show();
layer.draw();
}else if(key == 5){
// move 7.5 to 5
stage.find('#node_'+7.5).x(650);
stage.find('#node_'+7.5).y(100);
stage.find('#node_text_'+7.5).x(645);
stage.find('#node_text_'+7.5).y(90);
// hide 7.5 node, and show a NULL pointer.
stage.find('#nullptr').x(770);
stage.find('#nullptr').y(390);
stage.find('#nullptr').show();
layer.draw();
if(pc==1){
// highlight 7.5
stage.find('#node_'+7.5).fill("orange");
layer.draw();
pc = pc + 1;
}else if(pc==2)
// move 7.5 to 5
stage.find('#node_'+7.5).x(650);
stage.find('#node_'+7.5).y(100);
stage.find('#node_text_'+7.5).x(645);
stage.find('#node_text_'+7.5).y(90);
layer.draw();
pc = pc + 1;
}else if(pc==3){
// and then hide 7.5 node, and show a NULL pointer.
stage.find('#nullptr').x(770);
stage.find('#nullptr').y(390);
stage.find('#nullptr').show();
layer.draw();
}
}else if(key == 8){
line5.hide();
stage.find('#node_'+key).hide();

View File

@@ -8,7 +8,7 @@
<body>
<h1>Recursive Program: Delete a Node in a Binary Search Tree</h1>
<p>This animation shows how to delete a node in a binary search tree. Click the "next step" button to run the animation. <b>Note:</b> This animation as of now doesn't support the deletion of node 5.</p>
<p>This animation shows how to delete a node in a binary search tree. Click the "next step" button to run the animation.</p>
<label>delete node</label> <input type="text" id="textIn"><button onclick="start()">Start</button>
<br>