2010年10月5日

Example

摘要: 5.4.6 Example We're done with writing the code. Now, for clarification, let's run through an example designed to need lots of rebalancing along the way. Suppose that, starting with an empty AVL tree, ... 阅读全文

posted @ 2010-10-05 16:00 sohu2000000 阅读(114) 评论(0) 推荐(1) 编辑

Symmetric Case

摘要: 5.4.5 Symmetric Case Finally, we need to write code for the case that we chose not to discuss earlier, where the insertion occurs in the right subtree of y. All we have to do is invert the signs of ba... 阅读全文

posted @ 2010-10-05 15:59 sohu2000000 阅读(133) 评论(0) 推荐(1) 编辑

Step 3: Update Balance Factors

摘要: 5.4.3 Step 3: Update Balance Factors When we add a new node n to an AVL tree, the balance factor of n's parent must change, because the new node increases the height of one of the parent's subtrees. T... 阅读全文

posted @ 2010-10-05 14:25 sohu2000000 阅读(273) 评论(0) 推荐(0) 编辑

Step 4: Rebalance

摘要: 5.4.4 Step 4: Rebalance We've covered steps 1 through 3 so far. Step 4, rebalancing, is somewhat complicated, but it's the key to the entire insertion procedure. It is also similar to, but simpler tha... 阅读全文

posted @ 2010-10-05 01:27 sohu2000000 阅读(216) 评论(0) 推荐(1) 编辑

2010年10月4日

Step 2: Insert

摘要: 5.4.2 Step 2: Insert Following the search loop, q is the last non-null node examined, so it is the parent of the node to be inserted. The code below creates and initializes a new node as a child of q ... 阅读全文

posted @ 2010-10-04 15:08 sohu2000000 阅读(188) 评论(0) 推荐(1) 编辑

导航