lecture 11.4

1. rand(), 规定最大值,随机返回数字

2. splay tree(rebalance by themselves, 还有两种树也可以,下节课讲)

考虑parent,child,grandchild

double rotation

 

3. splay tree四种分类

 

 

 

 

4. 为了让tree rebalancing,可以利用rotation

left rotation:把右边的child变成root

right rotation:把左边的child变成root

 

n2=left(n1)

left(n1)=right(n2)

right(n2)=n1

 

 

 

 

 

 

 

5. insertion at root

 

6. rebalancing tree

把中间值移到root,故而需要counter记录数量有多少

partition(tree,i),将tree重新排列,i作为新的root

 

 

 

 

posted on 2019-11-06 10:35  Eleni  阅读(96)  评论(0编辑  收藏  举报

导航