type
Post
status
Published
date
Mar 31, 2023
slug
summary
tags
算法
category
学习思考
icon
password
文章为作者原创!!!

🤔 目标:使二叉树保持平衡

  1. 平衡二叉树
    1. 该树的所有的节点的左右节点之差小于等于1

    📝左旋和右旋

    左旋

    notion image
    1. 节点12为新插入的节点,从12依次开始寻找不平衡的节点。找到10
    1. 10节点 左-右=-1 —> 将支点左旋降级,变成左子节点
    notion image
    左旋的复杂情况
    notion image
     

    支点右旋

    notion image
    依次找到节点4后开始右旋
    复杂情况
    notion image

    平衡二叉树在添加节点时的特殊情况

    notion image
     

    🤗总结归纳

     
     
    💡
     
     
    关于NotionNext添加评论示例文章1

    三变青年
    三变青年
    一个普通的干饭人🍚
    公告
    type
    Notice
    status
    Published
    date
    Jul 2, 2021
    slug
    #
    summary
    类型为Notice的文章将被显示为公告,仅 hexo和next支持;仅限一个公告
    tags
    category
    icon
    password
    🎉本站基于NotionNext🎉
    -- 感谢您的支持 ---
    👏欢迎关注微信公众号👏
    👉一个大叔👈
    🎉由衷感谢NotionNext作者tangly 🎉
     
    最新评论
    Loading...