ã¹ããããªã¹ãã¯ããã©ã³ã¹ã®åããããªãŒã®ä»£ããã«äœ¿çšã§ããããŒã¿æ§é ã§ãã ãã©ã³ã¹ã¢ã«ãŽãªãºã ã¯å³å¯ã§ã¯ãªã確ççã§ãããããã¹ãããããããªã¹ãã§ã®èŠçŽ ã®æ¿å ¥ãšåé€ã¯ããã©ã³ã¹ããªãŒãããã¯ããã«ç°¡åã§é«éã§ãã
ã¹ããããªã¹ãã¯ããã©ã³ã¹ã®åããããªãŒã®ç¢ºççãªä»£æ¿æ段ã§ãã ä¹±æ°ãžã§ãã¬ãŒã¿ãŒã䜿çšããŠãã©ã³ã¹ãåãããŠããŸãã ã¹ãããã®ãããªã¹ãã¯ææªã®å Žåããã©ãŒãã³ã¹ãäœäžãããšããäºå®ã«ãããããããåžžã«çºçãããããªæäœã®ã·ãŒã±ã³ã¹ã¯ãããŸããïŒãµããŒãèŠçŽ ãã©ã³ãã ã«éžæããã¯ã€ãã¯ãœãŒãã¢ã«ãŽãªãºã ã®ããã«ïŒã ãã®ããŒã¿æ§é ãå€§å¹ ã«äžåè¡¡ã«ãªãããšã¯ã»ãšãã©ãããŸããïŒããšãã°ã250èŠçŽ ããã倧ããèŸæžã®å Žåãæ€çŽ¢ã«100äžåã®1æªæºã®äºæ³æéã®3åã®ç¢ºçãããããŸãïŒã
ããŒã¿æ§é ã®ãã©ã³ã¹ãåãããšã¯ãããããæ瀺çã«ãã©ã³ã¹ãåããããç°¡åã§ãã å€ãã®ã¿ã¹ã¯ã§ã¯ãã¹ããããªã¹ãã¯ããªãŒãããèªç¶ãªããŒã¿è¡šçŸã§ãã ã¢ã«ãŽãªãºã ã¯å®è£ ãç°¡åã§ãå®éã«ã¯ããã©ã³ã¹ã®åããããªãŒãããé«éã§ãã ããã«ãã¹ããããªã¹ãã¯ã¡ã¢ãªãéåžžã«å¹ççã«äœ¿çšããŸãã ãããã¯ãå¹³åã§çŽ1.33ïŒãŸãã¯ãã以äžïŒã®ãã€ã³ã¿ãŒã1ã€ã®èŠçŽ ã«åãŸããåèŠçŽ ã®ãã©ã³ã¹ãåªå 床ã«é¢ããè¿œå æ å ±ãå¿ èŠãšããªãããã«å®è£ ã§ããŸãã
ãªã³ã¯ãªã¹ãå ã®ã¢ã€ãã ãæ€çŽ¢ããã«ã¯ãåããŒãã調ã¹ãå¿ èŠããããŸãã
ãªã¹ãããœãŒããããŠä¿åããããã®2çªç®ã®ããŒãããšã«ããã«2ã€ã®ããŒããžã®ãã€ã³ã¿ãŒãå«ãŸããŠããå ŽåãIf n /2â+ 1ããŒãïŒ nã¯ãªã¹ãã®é·ãïŒãè¶ ããªãããã«ããå¿ èŠããããŸãã
åæ§ã«ã4çªç®ã®ããŒãããšã«4ã€å ã®ããŒããžã®ãã€ã³ã¿ãŒãå«ãŸããŠããå Žåãân /4â+ 2ããŒã以äžã調ã¹ãå¿ èŠããããŸãã
2 içªç®ã®ããŒãããšã«åæ¹ã«2 iåã®ããŒããžã®ãã€ã³ã¿ãŒãå«ãŸããŠããå Žåã衚瀺ããå¿ èŠãããããŒãã®æ°ã¯âlog2 nâã«åæžãããæ§é å ã®ãã€ã³ã¿ãŒã®ç·æ°ã¯2åã«ãªããŸãã
ãã®ããŒã¿æ§é ã¯ã¯ã€ãã¯æ€çŽ¢ã«äœ¿çšã§ããŸãããããŒãã®æ¿å ¥ãšåé€ã¯é ããªããŸãã
äžæµèŠçŽ ãžã®kãã€ã³ã¿ãå«ãããŒããã¬ãã«kã®ããŒããšåŒã³ãŸãã 2 içªç®ã®ããŒãããšã«2 iããŒãåæ¹ãžã®ãã€ã³ã¿ãŒãå«ãŸããå Žåãã¬ãã«ã¯æ¬¡ã®ããã«åæ£ãããŸããããŒãã®50ïŒ -ã¬ãã«1ã25ïŒ -ã¬ãã«2ã12.5ïŒ -ã¬ãã«3ãªã©ã ããããããŒãã¬ãã«ãåãæ¯çã§ã©ã³ãã ã«éžæãããå Žåã¯ã©ããªããŸããïŒ ããšãã°ã次ã®ããã«ïŒ
åããŒãã®ãã€ã³ã¿ãŒçªå·i㯠ãã¬ãã«i以äžã®æ¬¡ã®ããŒããåç §ãã以åã®ããã«æ£ç¢ºã«2 i -1ããŒãåæ¹ã§ã¯ãããŸããã æ¿å ¥ãšåé€ã«ã¯ãããŒã«ã«ã®å€æŽã®ã¿ãå¿ èŠã§ãã æ¿å ¥æã«ã©ã³ãã ã«éžæãããããŒãã¬ãã«ã¯å€æŽãããŸããã ã¬ãã«ãæ£ããå²ãåœãŠãããŠããªãå Žåãããã©ãŒãã³ã¹ãäœäžããå¯èœæ§ããããŸããããã®ãããªç¶æ³ã¯ãŸãã§ããããšã瀺ããŸãã ãããã®ããŒã¿æ§é ã¯ãäžéããŒããã¹ãããããããã®è¿œå ã®ãã€ã³ã¿ãŒãæã€ãªã³ã¯ãªã¹ãã§ãããšããäºå®ã®ãããç§ã¯ããããã¹ããããªã¹ããšåŒã³ãŸã ã
éå¶
ã¹ãããããããªã¹ãã«å®è£ ãããèŸæžã®èŠçŽ ãæ€çŽ¢ãæ¿å ¥ãåé€ããããã®ã¢ã«ãŽãªãºã ã«ã€ããŠèª¬æããŸãã æ€çŽ¢æäœã¯ãæå®ãããããŒã®å€ãè¿ãããããŒãèŠã€ãããªãã£ãããšãéç¥ããŸãã æ¿å ¥æäœã¯ãããŒãæ°ããå€ã«é¢é£ä»ããŸãïŒä»¥åã«ããŒããªãã£ãå Žåã¯ããŒãäœæããŸãïŒã åé€æäœã«ããããŒãåé€ãããŸãã ãæå°ããŒã®æ€çŽ¢ããã次ã®ããŒã®æ€çŽ¢ããªã©ããã®ããŒã¿æ§é ã«æäœãç°¡åã«è¿œå ããããšãã§ããŸãã
ãªã¹ãã®åèŠçŽ ã¯ãããŒããäœæããããšãã«ã¬ãã«ãã©ã³ãã ã«éžæãããããŒãã§ããããã§ã«ååšããèŠçŽ ã®æ°ã«é¢ä¿ãããŸããã ã¬ãã«iããŒãã«ã¯ã1ããiãŸã§ã®ã€ã³ããã¯ã¹ãä»ããããåã®ããŸããŸãªèŠçŽ ãžã®iãã€ã³ã¿ãŒãå«ãŸããŠããŸãã ããŒãèªäœã«ããŒãã¬ãã«ãä¿åããããšã¯ã§ããŸããã ã¬ãã«ã®æ°ã¯ãäºåã«éžæãããMaxLevelå®æ°ã«ãã£ãŠå¶éãããŸãã ãªã¹ãã¬ãã«ããã®ãªã¹ãã®æ倧ããŒãã¬ãã«ãšåŒã³ãŸãïŒãªã¹ãã空ã®å Žåãã¬ãã«ã¯1ã§ãïŒã ãªã¹ãã®èŠåºã ïŒå·ŠåŽã®å³ïŒã«ã¯ãã¬ãã«1ããMaxLevelãžã®ãã€ã³ã¿ãŒãå«ãŸããŠããŸãã ãã®ã¬ãã«ã®èŠçŽ ããŸã ãªãå Žåããã€ã³ã¿ãŒå€ã¯ç¹å¥ãªNILèŠçŽ ã§ãã
åæå
ãªã¹ãã«è¡šç€ºãããå¯èœæ§ã®ããããŒããã倧ããããŒãæã€NILèŠçŽ ãäœæããŸãã NILèŠçŽ ã¯ãã¹ãããããããªã¹ãããã¹ãŠå®äºããŸãã ãªã¹ãã¬ãã«ã¯1ã§ãããããŒå ã®ãã¹ãŠã®ãã€ã³ã¿ãŒã¯NILãåç §ããŸãã
èŠçŽ æ€çŽ¢
æé«ã¬ãã«ã®ãã€ã³ã¿ãŒããå§ããŠãç®çã®èŠçŽ ãè¶ ããªãèŠçŽ ãåç §ãããŸã§ããã€ã³ã¿ãŒã«æ²¿ã£ãŠé²ã¿ãŸãã 次ã«ã1ã€äžã®ã¬ãã«ã«ç§»åããåãã«ãŒã«ã«åŸã£ãŠåã³ç§»åããŸãã ã¬ãã«1ã«éããŠããã«å ã«é²ãããšãã§ããªãå Žåã¯ãæ¢ããŠããèŠçŽ ã®åã«ããŸãïŒååšããå ŽåïŒã
æ€çŽ¢ ïŒãªã¹ããsearchKeyïŒ
xïŒ=ãªã¹ã->ããããŒ
ïŒã«ãŒãäžå€åŒïŒxâããŒ<searchKey
for iïŒ=ãªã¹ãâã¬ãã«ããŠã³ 1 do
xâé²ã[i]âããŒ<searchKey do
xïŒ= xâãã©ã¯ãŒã[i]
ïŒxâããŒ<searchKeyâ€xâãã©ã¯ãŒã[1]âããŒ
xïŒ= xâãã©ã¯ãŒã[1]
xâããŒ= searchKeyã®å Žåã xâå€ãè¿ããŸã
ãã以å€ã®å Žåã¯å€±æãè¿ã ãŸã
ã¢ã€ãã ã®æ¿å ¥ãšåé€
ããŒããæ¿å ¥ãŸãã¯åé€ããã«ã¯ãæ€çŽ¢ã¢ã«ãŽãªãºã ã䜿çšããŠãæ¿å ¥ïŒãŸãã¯åé€ïŒãããåã®ãã¹ãŠã®èŠçŽ ãæ€çŽ¢ãã察å¿ãããã€ã³ã¿ãŒãæŽæ°ããŸãã
ãã®äŸã§ã¯ãã¬ãã«2ã®èŠçŽ ãæ¿å ¥ããŸããã
æ¿å ¥ ïŒãªã¹ããsearchKeyãnewValueïŒ
ããŒã«ã«æŽæ°[1..MaxLevel]
xïŒ=ãªã¹ã->ããããŒ
for iïŒ=ãªã¹ãâã¬ãã«ããŠã³ 1 do
xâé²ã[i]âããŒ<searchKey do
xïŒ= xâãã©ã¯ãŒã[i]
ïŒxâããŒ<searchKeyâ€xâé²ã[i]âããŒ
æŽæ°[i]ïŒ= x
xïŒ= xâãã©ã¯ãŒã[1]
xâããŒ= searchKeyã®å Žåã xâå€ïŒ= newValue
ä»ã«
lvlïŒ= randomLevelïŒïŒ
lvl>ãªã¹ãâã¬ãã«
for iïŒ=ãªã¹ãâã¬ãã«+ 1 ãã lvl do
æŽæ°[i]ïŒ=ãªã¹ãâããããŒ
ãªã¹ãâã¬ãã«ïŒ= lvl
xïŒ= makeNodeïŒlvlãsearchKeyãvalueïŒ
for iïŒ=ã¬ãã«1
xâ転é[i]ïŒ=æŽæ°[i]â転é[i]
æŽæ°[i]â転é[i]ïŒ= x
åé€ ïŒãªã¹ããsearchKeyïŒ
ããŒã«ã«æŽæ°[1..MaxLevel]
xïŒ=ãªã¹ã->ããããŒ
for iïŒ=ãªã¹ãâã¬ãã«ããŠã³ 1 do
xâé²ã[i]âããŒ<searchKey do
xïŒ= xâãã©ã¯ãŒã[i]
æŽæ°[i]ïŒ= x
xïŒ= xâãã©ã¯ãŒã[1]
xâkey = searchKeyã®å Žå
for iïŒ=ãªã¹ãããã«ã¯1 =ã¬ãã«
æŽæ°[i]â転é[i]â xã®å Žåã ãã¬ãŒã¯
æŽæ°[i]â転é[i]ïŒ= xâ転é[i]
ç¡æïŒxïŒ
äžæ¹ããªã¹ãâã¬ãã«> 1 ããã³ãªã¹ãâããããŒâ転é[ãªã¹ãâã¬ãã«] = NIL do
ãªã¹ãâã¬ãã«ïŒ=ãªã¹ãâã¬ãã«-1
æ¿å ¥ïŒãŸãã¯åé€ïŒé åã®åã®èŠçŽ ãèšæ¶ããããã«ã æŽæ°é åã䜿çšãããŸãã æŽæ°[i]èŠçŽ ã¯ãæŽæ°å Žæã®å·Šã®çªå·ããå³ç«¯ã®ããŒãïŒã¬ãã«i以äžïŒãžã®ãã€ã³ã¿ãŒã§ãã
æ¿å ¥ãããããŒãã®ã©ã³ãã ã«éžæãããã¬ãã«ããªã¹ãå šäœã®ã¬ãã«ããã倧ããããšãå€æããå ŽåïŒã€ãŸãããã®ãããªã¬ãã«ã®ããŒãããŸã ãªãå ŽåïŒããªã¹ãã®ã¬ãã«ãäžããããããŒãžã®ãã€ã³ã¿ãŒã§æŽæ°é åã®å¯Ÿå¿ããèŠçŽ ãåæåããŸãã åé€ãããã³ã«ãæ倧ã¬ãã«ã®ããŒããåé€ãããã©ããã確èªããåé€ããå Žåã¯ãªã¹ãã®ã¬ãã«ãäžããŸãã
ã¬ãã«çªå·ã®çæ
åã«ãã¬ãã«iãã€ã³ã¿ãŒãå«ãããŒãã®ååã«ã¬ãã«i +1ããŒããžã®ãã€ã³ã¿ãŒãå«ãŸããå Žåã®ããŒãã¬ãã«ã®ååžã瀺ããŸããã ããžãã¯å®æ°1/2ãåãé€ãã«ã¯ãã¬ãã«iã®ããŒããžã®ãã€ã³ã¿ãŒãå«ãã¬ãã«iã®ããŒãã®å²åãpã§ç€ºããŸãã æ°ããé ç¹ã®ã¬ãã«çªå·ã¯ã次ã®ã¢ã«ãŽãªãºã ã䜿çšããŠã©ã³ãã ã«çæãããŸãã
randomLevel ïŒïŒ
ã¬ãã«ïŒ= 1
ïŒrandomïŒïŒã¯ãååºé[0 ... 1ïŒã§ä¹±æ°ãè¿ããŸã
ã©ã³ãã ïŒïŒ<p ããã³ lvl <MaxLevel do
lvlïŒ= lvl + 1
ã¬ãã«ãè¿ã
ã芧ã®ãšããããªã¹ãå ã®èŠçŽ ã®æ°ã¯çæã«é¢ä¿ããŠããŸããã
ã©ã®ã¬ãã«ãæ¢ãå§ããŸããïŒ LïŒnïŒã®å®çŸ©
p = 1/2ã§çæããã16èŠçŽ ã®ã®ã£ããããããªã¹ãã§ã¯ãã¬ãã«1ã®9èŠçŽ ãã¬ãã«2ã®3èŠçŽ ãã¬ãã«3ã®3èŠçŽ ãããã³ã¬ãã«14ã®1èŠçŽ ãå«ãŸããŠããããšããããŸãïŒããã¯å¯èœæ§ã¯äœãã§ããå¯èœã§ãïŒ ã ããã«å¯ŸåŠããã«ã¯ïŒ æšæºã®ã¢ã«ãŽãªãºã ã䜿çšããã¬ãã«14ããæ€çŽ¢ããå Žåãå€ãã®ç¡é§ãªäœæ¥ãè¡ããŸãã
ã©ãã§æ€çŽ¢ãéå§ããæ¹ãè¯ãã§ããïŒ ç§ãã¡ã®ç 究ã§ã¯ãã¬ãã«Lã§æ€çŽ¢ãéå§ããããšãæåã§ããããšã瀺ãããŠããŸããã¬ãã«Lã§ã¯ã1 / pããŒããæåŸ ãããŸãã ããã¯ã L = log 1 / p nã®ãšãã«èµ·ãããŸãã ãããªãè°è«ã®äŸ¿å®äžãé¢æ°log 1 / p nãL ïŒ n ïŒãšããŠç€ºããŸãã
äºæ³å€ã«å€§ããªããŒãã®åé¡ã解決ããã«ã¯ãããã€ãã®æ¹æ³ããããŸãã
- èžæ°ãçºããªãã§ãã ãã ïŒå ã¯æ°ã«ããªãã§ã幞ãã«ãªã£ãŠãã ããïŒã ãªã¹ãã«ããæé«ã¬ãã«ããæ€çŽ¢ãéå§ããŠãã ããã åŸã§èŠãããã«ã nåã®ã¢ã€ãã ã®ãªã¹ãã®ã¬ãã«ãLïŒnïŒãããããªãé«ã確çã¯éåžžã«å°ããã§ãã ãã®ãããªãœãªã¥ãŒã·ã§ã³ã§ã¯ãäºæ³ãããæ€çŽ¢æéã«å°ããªå®æ°ã®ã¿ãè¿œå ãããŸãã ãã®ã¢ãããŒãã¯ãäžèšã®ã¢ã«ãŽãªãºã ã§äœ¿çšãããŸãã
- å¿ èŠä»¥äžã®ã¹ããŒã¹ã䜿çšããªãã§ãã ããã èŠçŽ ã«ã¯14åã®ãã€ã³ã¿ãŒãå«ããããšãã§ããŸããã14åãã¹ãŠã䜿çšããå¿ èŠã¯ãããŸããããã®ãã¡ã®LïŒnïŒã®ã¿ã䜿çšã§ããŸãã ãããå®è£ ããæ¹æ³ã¯ããã€ããããŸããããããã¯ãã¹ãŠã¢ã«ãŽãªãºã ãè€éã«ããããã©ãŒãã³ã¹ã®é¡èãªåäžã«ã€ãªãããŸããã ãã®æ¹æ³ã®äœ¿çšã¯æšå¥šãããŸããã
- ãã¥ãŒããä¿®æ£ããŸãã ãªã¹ãå ã®ããŒãã®æ倧ã¬ãã«ãã倧ããã¬ãã«ãçæãããå Žåãããã¯æ£ç¢ºã«1以äžã§ãããšåçŽã«ä¿¡ããŠããŸããçè«äžãå®éã«ã¯ãããã¯ããŸãæ©èœããŠããããã§ãã ãããããã®ã¢ãããŒãã§ã¯ãã¢ã«ãŽãªãºã ã®è€éããåæããèœåãå®å šã«å€±ããŸãã ããŒãã¬ãã«ã¯å®å šã«ã©ã³ãã ã§ã¯ãªããªããŸããã ããã°ã©ããŒã¯ãã®æ¹æ³ãèªç±ã«äœ¿çšã§ããŸãããçè«å®¶ã¯ãããé¿ããã»ããããã§ãããã
MaxLevelã®éžæ
äºæ³ãããã¬ãã«æ°ã¯LïŒnïŒã§ããããã MaxLevel = L ïŒ N ïŒãéžæããã®ãæåã§ããããã§ã Nã¯ã¹ããããªã¹ãã®èŠçŽ ã®æ倧æ°ã§ãã ããšãã°ã p = 1/2ã®å Žåã MaxLevel = 16ã¯2 16æªæºã®èŠçŽ ãå«ããªã¹ãã«é©ããŠããŸãã
ã¢ã«ãŽãªãºã åæ
æ€çŽ¢ãæ¿å ¥ãããã³åé€ã®æäœã§ã¯ãé©åãªã¢ã€ãã ãèŠã€ããã®ã«æãæéãããããŸãã æ¿å ¥ããã³åé€ããã«ã¯ãæ¿å ¥ãŸãã¯åé€ãããããŒãã®ã¬ãã«ã«æ¯äŸããŠè¿œå ã®æéãå¿ èŠã§ãã èŠçŽ ã®æ€çŽ¢æéã¯ãæ€çŽ¢ããã»ã¹ã§æž¡ãããããŒãã®æ°ã«æ¯äŸããããŒãã®ã¬ãã«ã®ååžã«äŸåããŸãã
確çè«çå²åŠ
ã®ã£ãããªã¹ãã®æ§é ã¯ããã®ãªã¹ãã®èŠçŽ æ°ãšä¹±æ°ãžã§ãã¬ãŒã¿ãŒã®å€ã«ãã£ãŠã®ã¿æ±ºå®ãããŸãã ãªã¹ããååŸããæäœã®é åºã¯éèŠã§ã¯ãããŸããã ãŠãŒã¶ãŒã¯ããŒãã®ã¬ãã«ã«ã¢ã¯ã»ã¹ã§ããªããšæ³å®ããŸããããã§ãªãå ŽåããŠãŒã¶ãŒã¯ã¢ã«ãŽãªãºã ãææªã®æéåäœãããã¬ãã«ã1以å€ã®ãã¹ãŠã®ããŒããåé€ã§ããŸãã
åãããŒã¿æ§é ã§ã®é 次æäœã®å Žåãå®è¡æéã¯ç¬ç«ããã©ã³ãã å€æ°ã§ã¯ãããŸããã åãèŠçŽ ãæ€çŽ¢ãã2ã€ã®é£ç¶ããæäœã«ã¯ããŸã£ããåãæéãããããŸãã
äºæ³æ€çŽ¢æéã®åæ
æ€çŽ¢äžã«æåŸãã暪æãããã¹ãã€ãŸã å·Šäžã«ç§»åããŸãã ãªã¹ãå ã®ããŒãã®ã¬ãã«ã¯æ€çŽ¢æã«æ¢ç¥ã§ãããåºå®ãããŠããŸãããããŒãã®ã¬ãã«ã¯ãæåŸãã移åãããšãã«ããŒãã®ã¬ãã«ã«éãããšãã«ã®ã¿æ±ºå®ããããšæ³å®ããŠããŸãã
ãã¹äžã®ä»»æã®æç¹ã§ã次ã®ç¶æ³ã«ãããŸãã
ããŒãxã® içªç®ã®ãã€ã³ã¿ãŒãèŠãŠã xã®å·ŠåŽã«ããããŒãã®ã¬ãã«ãç¥ããŸããã ãŸãã xã®æ£ç¢ºãªã¬ãã«ã¯ããããŸããããå°ãªããšãiã§ãªããã°ãªããŸããã xããªã¹ãã®èŠåºãã§ã¯ãªããšä»®å®ããŸãïŒããã¯ãªã¹ããå·Šã«ç¡éã«å±éããŠãããšä»®å®ããã®ãšåãã§ãïŒã ã¬ãã«xãiã®å Žåãç¶æ³bã«ãªããŸãã ã¬ãã«xã iãã倧ããå Žåãç¶æ³cã«ãªããŸãã ç¶æ³cã«ãã確çã¯pã§ãã ãããçºçãããã³ã«ã1ã¬ãã«äžã«ç§»åããŸãã C ïŒ k ïŒãkåäžã«ç§»åãããšãã®æ»ãæ€çŽ¢ãã¹ã®äºæ³ãããé·ããšããŸãã
C ïŒ0ïŒ= 0
C ïŒ k ïŒ=ïŒ1- p ïŒïŒ ã·ãã¥ãšãŒã·ã§ã³bã®çµè·¯é· ïŒ+ p ïŒ ã·ãã¥ãšãŒã·ã§ã³cã®çµè·¯é· ïŒ
ç°¡çŽ åïŒ
C ïŒ k ïŒ=ïŒ1- p ïŒïŒ1 + C ïŒ k ïŒïŒ+ pâ ïŒ1 + C ïŒ k -1ïŒïŒ
C ïŒ k ïŒ= 1 + C ïŒ k ïŒ-pâ CïŒ k ïŒ+ pâ CïŒ k -1ïŒ
C ïŒ k ïŒ= 1 / p + C ïŒ k -1ïŒ
C ïŒ k ïŒ= k / p
ãªã¹ããç¡éã§ãããšããæã ã®ä»®å®ã¯æ²èŠ³çã§ãã 巊端ã®èŠçŽ ã«å°éãããšãå·Šã«ç§»åããã®ã§ã¯ãªããåžžã«äžã«ç§»åããŸãã ããã«ããã nåã®èŠçŽ ã®ãªã¹ãã§ãã¬ãã«1ã®ããŒãããã¬ãã«L ïŒ n ïŒã®ããŒããŸã§ã®äºæ³ãã¹é·ã®äžéïŒ L ïŒ n ïŒ-1ïŒ/ pãåŸãããŸãã
ãã®æšè«ã䜿çšããŠã¬ãã«L ïŒ n ïŒã®ããŒãã«å°éããŸãããæ®ãã®æ¹æ³ã§ã¯ä»ã®èæ ®äºé ã䜿çšãããŸãã å·Šãžã®æ®ãã®ç§»åã®æ°ã¯ããªã¹ãå šäœã§ã¬ãã«L ïŒ n ïŒä»¥äžã®ããŒãã®æ°ã«ãã£ãŠå¶éãããŸãã ãã®ãããªããŒãã®æãå¯èœæ§ã®é«ãæ°ã¯ã1 / pã§ãã
ãŸããã¬ãã«L ïŒ n ïŒãããªã¹ãã®æ倧ã¬ãã«ã«ç§»åããŠããŸãã ãªã¹ãã®æ倧ã¬ãã«ãkãã倧ãã確çã¯1-ïŒ1-p k ïŒ nã§ãããããã¯np k以äžã§ãã äºæ³ãããæ倧ã¬ãã«ã¯L ïŒ n ïŒ+ 1 /ïŒ1- p ïŒä»¥äžã§ãããšèšç®ã§ããŸãã ãã¹ãŠããŸãšãããšã nåã®èŠçŽ ã®ãªã¹ãã®æ€çŽ¢ãã¹ã®äºæ³ãããé·ããååŸããŸã
<= L ïŒ n ïŒ/ p + 1 /ïŒ1- p ïŒã
ãŸãã¯O ïŒlog n ïŒã
æ¯èŒã®æ°
æ€çŽ¢ãããã¹ã®é·ããããããŸããã ãŠãããããšã«å¿ èŠãªæ¯èŒã®æ°ã¯ããã¹ã®é·ããè¶ ããŠããŸãïŒãã¹ã®åã¹ãããã§æ¯èŒãè¡ãããŸãïŒã
確ççåæ
ããŸããŸãªæ€çŽ¢ãã¹ã®é·ãã®ç¢ºçååžãèæ ®ããããšãã§ããŸãã 確çåæã¯ããè€éã§ãïŒå ã®èšäºã®æåŸã«ãããŸãïŒã ããã«ãããæ€çŽ¢ãã¹ã®é·ãããæå®ãããåæ°ãè¶ ããŠäºæ³ãè¶ ãã確çãäžããæšå®ã§ããŸãã åæçµæïŒ
ããã¯ãæäœãäºæ³ãããå€§å¹ ã«é·ãããã確çã®äžéã®ã°ã©ãã§ãã 瞊軞ã¯ãæ€çŽ¢ãã¹ã®é·ããããã¹ã®äºæ³ãããé·ãããã暪軞ã§é 延ããåæ°ã ãé·ããªã確çã瀺ããŠããŸãã ããšãã°ãp = 1/2ããã³n = 4096ã®å Žåãçµæã®ãã¹ãäºæ³ãã3åé·ããªã確çã¯1 / 200,000,000æªæºã§ãã
Pã®éžæ
ãã®è¡šã¯ãæ£èŠåãããæ€çŽ¢æéãšãããŸããŸãªpå€ã«å¿ èŠãªã¡ã¢ãªéã瀺ããŠããŸãã
p | æ£èŠåãããæ€çŽ¢æé
ïŒããªãã¡ãæ£èŠåãããL ïŒ n ïŒ/ p ïŒ | ããŒããããã®ãã€ã³ã¿ãŒã®å¹³åæ°
ïŒã€ãŸã1 /ïŒ1- p ïŒïŒ |
---|---|---|
1/2 | 1 | 2 |
1 / e | 0.94 ... | 1.58 ... |
1/4 | 1 | 1.33 ... |
1/8 | 1.33 ... | 1.14 ... |
1/16 | 2 | 1.07 ... |
pãå°ãããããšãæäœã®æéçåºããã倧ãããªããŸãã 1 / pã2ã®ã¹ãä¹ã§ããå Žåãã©ã³ãã ãããã®ã¹ããªãŒã ããã¬ãã«çªå·ãçæãããšäŸ¿å©ã§ãïŒçæã«ã¯ãå¹³åã§ïŒlog 2 1 / p ïŒ/ïŒ1- p ïŒã©ã³ãã ããããå¿ èŠã§ãïŒã L ïŒ n ïŒïŒãã ãL ïŒ n ïŒ/ pã§ã¯ãªãïŒã«é¢é£ãããªãŒããŒããããããããã p = 1/4ïŒ1/2ã§ã¯ãªãïŒãéžæãããšãã¢ã«ãŽãªãºã ã®è€éãã®å®æ°ããããã«æžå°ããŸãã p = 1/4ãéžæããããšããå§ãããŸãããæäœæéã®åºãããé床ãããéèŠãªå Žåã¯ã1/2ãéžæããŸãã
è€æ°ã®æäœ
æäœã®ã·ãŒã±ã³ã¹ã®äºæ³åèšæéã¯ãã·ãŒã±ã³ã¹å ã®åæäœã®äºæ³æéã®åèšã«çãããªããŸãã ãããã£ãŠã nåã®èŠçŽ ã®ããŒã¿æ§é ã«ãããmåã®æ€çŽ¢æäœã®ã·ãŒã±ã³ã¹ã®äºæ³æéã¯O ïŒ m * log n ïŒã§ãã ãã ããæ€çŽ¢æäœã®ãã¿ãŒã³ã¯ãæäœã·ãŒã±ã³ã¹å šäœã®å®éã®æéã®ååžã«åœ±é¿ããŸãã
åãããŒã¿æ§é ã§åãèŠçŽ ãæ¢ããšãäž¡æ¹ã®æäœã«ãŸã£ããåãæéãããããŸãã ãããã£ãŠãåèšæéã®åæ£ïŒæ£åžïŒã¯ã1ã€ã®æ€çŽ¢æäœã®åæ£ã®4åã«ãªããŸãã 2ã€ã®èŠçŽ ã®æ€çŽ¢æéãç¬ç«ããã©ã³ãã å€æ°ã§ããå Žåãåèšæéã®åæ£ã¯åã ã®æäœã®å®è¡æéã®åæ£ã®åèšã«çãããªããŸãã åãèŠçŽ ãäœåºŠãæ€çŽ¢ãããšãåæ£ãæ倧åãããŸãã
æ§èœè©Šéš
ã¹ãããããããªã¹ãã®ããã©ãŒãã³ã¹ãä»ã®ããŒã¿æ§é ãšæ¯èŒããŸãã ãã¹ãŠã®å®è£ ã¯ãæ倧ã®ããã©ãŒãã³ã¹ã®ããã«æé©åãããŠããŸãã
ããŒã¿æ§é | æ€çŽ¢ãã | æ¿å ¥ | åé€ãã |
---|---|---|---|
ãªã¹ããã¹ããã | 0.051ããªç§ïŒ1.0ïŒ | 0.065ããªç§ïŒ1.0ïŒ | 0.059ããªç§ïŒ1.0ïŒ |
éååž°çãªAVLããªãŒ | 0.046ããªç§ïŒ0.91ïŒ | 0.10ããªç§ïŒ1.55ïŒ | 0.085ããªç§ïŒ1.46ïŒ |
ååž°çãª2ã3æ¬ã®æš | 0.054ããªç§ïŒ1.05ïŒ | 0.21ããªç§ïŒ3.2ïŒ | 0.21ããªç§ïŒ3.65ïŒ |
èªå·±å¶åŸ¡ããªãŒïŒ | |||
äžããäžãžæ¡å€§ïŒãããããŠã³ã®åºããïŒ | 0.15ããªç§ïŒ3.0ïŒ | 0.16ããªç§ïŒ2.5ïŒ | 0.18ããªç§ïŒ3.1ïŒ |
äžããäžãžæ¡å€§ïŒäžããäžãžïŒ | 0.49ããªç§ïŒ9.6ïŒ | 0.51ããªç§ïŒ7.8ïŒ | 0.53ããªç§ïŒ9.0ïŒ |
ãã¹ãã¯Sun-3 / 60ãã·ã³ã§å®è¡ããã2 16åã®èŠçŽ ãå«ãããŒã¿æ§é ã§å®è¡ãããŸããã æ¬åŒ§å ã®å€ã¯ãçç¥ããããªã¹ãïŒæéåäœïŒã«å¯Ÿããçžå¯Ÿæéã§ãã èŠçŽ ã®æ¿å ¥ããã³åé€ã®ãã¹ãã§ã¯ãã¡ã¢ãªç®¡çïŒããšãã°ãmallocããã³freeã®CåŒã³åºãïŒã«è²»ããããæéã¯èæ ®ãããŸããã§ããã
ã¹ãããããããªã¹ãã«ã¯ãä»ã®ããŒã¿æ§é ãããå€ãã®æ¯èŒæŒç®ãå¿ èŠã§ããããšã«æ³šæããŠãã ããïŒäžèšã®ã¢ã«ãŽãªãºã ã§ã¯ãå¹³åL ïŒ n ïŒ/ p + 1 /ïŒ1 + p ïŒæŒç®ãå¿ èŠã§ãïŒã å®æ°ãããŒãšããŠäœ¿çšãããšãã¹ããããªã¹ãã§ã®æäœã¯AVLããªãŒã®éååž°çå®è£ ãããè¥å¹²é ããªããã¹ããããªã¹ãã§ã®æ€çŽ¢ã¯2-3ããªãŒã§ã®æ€çŽ¢ããããããã«é ããªããŸããïŒãã ããæ¿å ¥ãšåé€ãã¹ã®ãããªã¹ãã§ã¯ã2ã3æ¬ã®ããªãŒãååž°çã«å®è£ ãããããé«éã§ããã æ¯èŒæäœãéåžžã«é«äŸ¡ãªå Žåãã¢ã«ãŽãªãºã ãå€æŽããŠãç®çã®ããŒãä»ã®ããŒãã®ããŒãšããŒãããšã«è€æ°åæ¯èŒãããªãããã«ããããšãã§ããŸãã p = 1/2ã®å Žåãæ¯èŒåæ°ã®äžéã¯7/2 + 3/2 * log 2 nã§ãã
ãªã¯ãšã¹ãã®äžåçãªåé
èªå·±èª¿æŽããªãŒã¯ãèŠæ±ã®äžåçãªåæ£ã«é©å¿ã§ããŸãã ãã¹ãæã€ãªã¹ãã¯ãèªå·±èª¿æŽããªãŒãããã¯ããã«é«éã§ãããããèªå·±èª¿æŽããªãŒã¯ãã¯ãšãªã®åæ£ãéåžžã«äžåäžãªå Žåã«ã®ã¿é«éã«ãªããŸãã èªå·±èª¿æŽãªã¹ããçç¥ããŠéçºããããšã¯ã§ããŸããããããã«ã¯å®çšçãªæå³ããªããå ã®å®è£ ã®åçŽããšããã©ãŒãã³ã¹ãæãªããããããŸããã§ããã ã¢ããªã±ãŒã·ã§ã³ã§äžåäžãªèŠæ±ãäºæ³ãããå Žåãèªå·±èª¿æŽããªãŒã®äœ¿çšãŸãã¯ãã£ãã·ã¥ã®è¿œå ãæãŸããã§ãããã
ãããã«
çè«çãªèŠ³ç¹ãããã¹ããããªã¹ãã¯å¿ èŠãããŸããã ãã©ã³ã¹ã®ãšããããªãŒã¯ãåãæäœãå®è¡ã§ããææªã®å ŽåïŒãªã¹ãã®ã¹ããããšã¯å¯Ÿç §çã«ïŒè€é床ãé«ããªããŸãã ãã ãããã©ã³ã¹ã®åããããªãŒã®å®è£ ã¯å°é£ãªã¿ã¹ã¯ã§ããããã®çµæã倧åŠã§ã®å®éšå®€äœæ¥ãé€ããŠãå®éã«å®çŸãããããšã¯ã»ãšãã©ãããŸããã
ã¹ããããªã¹ãã¯ãã»ãšãã©ã®å Žåããã©ã³ã¹ã®åããããªãŒã®ä»£ããã«äœ¿çšã§ããåçŽãªããŒã¿æ§é ã§ãã ã¢ã«ãŽãªãºã ã®å®è£ ãæ¡åŒµãå€æŽã¯éåžžã«ç°¡åã§ãã ã¹ãããããããªã¹ãã§ã®æäœã®åŸæ¥ã®å®è£ ã¯ããã©ã³ã¹ã®åããããªãŒã§ã®é«åºŠã«æé©åãããå®è£ ãšã»ãŒåããããéããé«åºŠã«æé©åãããŠããªãéåžžã®å®è£ ãããããªãé«éã§ãã