以当前对象为基准 父:当前节点父节点 父父:当前节点父节点的父节点 父左:当前节点父节点的左节点 父右:当前节点父节点的右节点 rotateRight:右旋 rotateLeft:左旋 按照程序逻辑 Created with Raphaël 2.2.0 开始 非空&非根&父红 父=父父左? 父父右红? 父变黑,父父右变黑, 父父变红,该节点=父父 本节点=父右? 该节点=父 rotateLeft(该节点) 父变黑,父父变红, rotateRight(父父) 父父左红? 父变黑,父父左变黑, 父父变红,该节点=父父 根变黑 结束 该节点=父左? 该节点=父, rotateRight(该节点) 父变黑,父父变红, rotateLeft(父父) yes no yes no yes no yes no yes no yes no 形象点说 Created with Raphaël 2.2.0 开始 不空&不是根&父红 父为左节点? 父父右红? 父变黑,父父右变黑, 父父变红,该节点=父父 本节点为右节点? 该节点=父 该节点左旋 父变黑,父父变红, 父父右旋 父父左红? 父变黑,父父左变黑, 父父变红,该节点=父父 根变黑 结束 该节点为左节点? 该节点=父, 该节点右旋 父变黑,父父变红, 父父左旋 yes no yes no yes no yes no yes no yes no