pfds ex3 9
DESCRIPTION
Explanation for Purely Functional Data Structure (C. Okasaki) Exercise 3.9TRANSCRIPT
![Page 1: Pfds ex3 9](https://reader033.vdocuments.mx/reader033/viewer/2022052311/556a3ca1d8b42a4a1e8b4726/html5/thumbnails/1.jpg)
PFDS EX. 3.9 竹井(@shtaag)
2011年12月17日土曜日
![Page 3: Pfds ex3 9](https://reader033.vdocuments.mx/reader033/viewer/2022052311/556a3ca1d8b42a4a1e8b4726/html5/thumbnails/3.jpg)
FROMORDLIST
•連続した値のlistからRedBlackTreeを形成すると、、
2011年12月17日土曜日
![Page 4: Pfds ex3 9](https://reader033.vdocuments.mx/reader033/viewer/2022052311/556a3ca1d8b42a4a1e8b4726/html5/thumbnails/4.jpg)
こうなる
Z
Y
X
Z
Y
X
連続したKeyのインサートではこのバランスが連続で呼ばれる(これ違うかもしれません...木の伸びる方向が逆?)
この図は左右反転している???
2011年12月17日土曜日
![Page 5: Pfds ex3 9](https://reader033.vdocuments.mx/reader033/viewer/2022052311/556a3ca1d8b42a4a1e8b4726/html5/thumbnails/5.jpg)
これを、基数2で表してみる
2011年12月17日土曜日
![Page 6: Pfds ex3 9](https://reader033.vdocuments.mx/reader033/viewer/2022052311/556a3ca1d8b42a4a1e8b4726/html5/thumbnails/6.jpg)
PENNANT
rank = 2
•完全木と一つのNodeから成る• rank r のpennantは、2rのNodeを持つ
2011年12月17日土曜日
![Page 7: Pfds ex3 9](https://reader033.vdocuments.mx/reader033/viewer/2022052311/556a3ca1d8b42a4a1e8b4726/html5/thumbnails/7.jpg)
EXPRESSION WITH PENNANTS
2011年12月17日土曜日
![Page 8: Pfds ex3 9](https://reader033.vdocuments.mx/reader033/viewer/2022052311/556a3ca1d8b42a4a1e8b4726/html5/thumbnails/8.jpg)
EXPRESSION WITH PENNANTS
※ 0,1ではなく、1,2を使用する
2011年12月17日土曜日
![Page 9: Pfds ex3 9](https://reader033.vdocuments.mx/reader033/viewer/2022052311/556a3ca1d8b42a4a1e8b4726/html5/thumbnails/9.jpg)
EXPRESSION WITH PENNANTS
(22)2
(21 x 2, 20 x 2)2
==
2011年12月17日土曜日
![Page 10: Pfds ex3 9](https://reader033.vdocuments.mx/reader033/viewer/2022052311/556a3ca1d8b42a4a1e8b4726/html5/thumbnails/10.jpg)
(21{N})だと高さを抑えられる
(23 x 2, 22 x 1, 21 x 1, 20 x 1)
2011年12月17日土曜日
![Page 11: Pfds ex3 9](https://reader033.vdocuments.mx/reader033/viewer/2022052311/556a3ca1d8b42a4a1e8b4726/html5/thumbnails/11.jpg)
実装
2011年12月17日土曜日
![Page 12: Pfds ex3 9](https://reader033.vdocuments.mx/reader033/viewer/2022052311/556a3ca1d8b42a4a1e8b4726/html5/thumbnails/12.jpg)
実装
s1 + 1 = s2, s2 + 1 = (s + 1)1を表現
2011年12月17日土曜日
![Page 13: Pfds ex3 9](https://reader033.vdocuments.mx/reader033/viewer/2022052311/556a3ca1d8b42a4a1e8b4726/html5/thumbnails/13.jpg)
実装
2011年12月17日土曜日