From 73b283c87fcbd01e870714836403bdffceecbb5d Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Wed, 26 Mar 2025 11:41:05 -0400 Subject: [PATCH] split into 3 steps --- animations/trees/delete_node/delete_node.js | 30 ++++++++++++++------- animations/trees/delete_node/index.html | 2 +- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/animations/trees/delete_node/delete_node.js b/animations/trees/delete_node/delete_node.js index 1b0b6b6..0a7fafd 100644 --- a/animations/trees/delete_node/delete_node.js +++ b/animations/trees/delete_node/delete_node.js @@ -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(); diff --git a/animations/trees/delete_node/index.html b/animations/trees/delete_node/index.html index ad56b28..4580ddd 100644 --- a/animations/trees/delete_node/index.html +++ b/animations/trees/delete_node/index.html @@ -8,7 +8,7 @@

Recursive Program: Delete a Node in a Binary Search Tree

-

This animation shows how to delete a node in a binary search tree. Click the "next step" button to run the animation. Note: This animation as of now doesn't support the deletion of node 5.

+

This animation shows how to delete a node in a binary search tree. Click the "next step" button to run the animation.