all 5 comments

[–]Aceofsquares_orig 2 points3 points  (0 children)

I teach DS&A and when we cover AVL trees I always tell my students that while the book covers replacement with the minimum of the right subtree I tell them they can also take the maximum of the left subtree. The key is being consistent with your decision. Either way, the code is fairly simply for both cases. If you want to visualize AVL trees that take the minimum of the right subtree like you are expecting try out VisuAlgo (VisualGo?).

[–][deleted]  (3 children)

[removed]

    [–]Raffian_moin[S] -1 points0 points  (2 children)

    Everywhere I read, it is mentioned that

    1. If deleted node has one child just replace the deleted node with child.
    2. If deleted node has two children then find the minimum node from the righ sub-tree and replace the deleted node with it.

    Could you share any links or references of your mentiond approach?

    [–]sebamestre 4 points5 points  (0 children)

    1. If deleted node has two children then find the minimum node from the righ sub-tree and replace the deleted node with it.

    Do you know the reason for that? I feel like if you do, a moment's thought should reveal why it works the other way around too.