- ã©ã³ã¿ã€ã -ä¿èšŒOïŒnlognïŒã
- OïŒ1ïŒè¿œå ã¡ã¢ãªã䜿çšããŸãã
- åäžãªã³ã¯ãªã¹ãã®ããŒã¿ã®äžŠã¹æ¿ãã®é©çšå¯èœæ§ïŒãã ããããã«éå®ãããŸããïŒã
3ã€ã®å¶éãã¹ãŠã®äºçŽïŒ
- ä¿èšŒãããOïŒnlognïŒã¯ãããšãã°ãã¯ã€ãã¯ãœãŒãã®å¹³åæéãé©åã§ãªãããšãæå³ããŸããOïŒnlognïŒã¯ãææªã®å ¥åã§ãã£ãŠãååŸããå¿ èŠããããŸãã
- ååž°ã¯ãååž°åŒã³åºãã®ã¹ã¿ãã¯ãæ ŒçŽããããã®OïŒlognïŒã¡ã¢ãªãæå³ããããã䜿çšã§ããŸããã
- ãœãŒããããé åã®èŠçŽ ãžã®ä»»æã®ã¢ã¯ã»ã¹ã¯ãããŸãããã€ãã¬ãŒã¿ãä»»æã®èŠçŽ ããé£æ¥ããèŠçŽ ïŒOïŒ1ïŒãè¶ ããïŒã«ã®ã¿ç§»åããäžæ¹åïŒãªã¹ãã®åæ¹ïŒã«ã®ã¿ç§»åã§ããŸãã ãªã¹ãèªäœãå€æŽããããšã¯ã§ããŸããïŒæ¬¡ã®èŠçŽ ãžã®ãã€ã³ã¿ãäžåãããïŒã
é åã®èŠçŽ ã«ã€ããŠç¥ã£ãŠãããã¹ãŠã®æ å ±ã¯ããããããã¹ãŠç·åœ¢ã«é åºä»ããããã»ããã圢æãããšããããšã§ãã ã§ããããšã¯ãé åã®2ã€ã®èŠçŽ ãæ¯èŒãïŒOïŒ1ïŒã®å ŽåïŒããããã亀æããããšã§ãïŒOïŒ1ïŒã®å ŽåãïŒã
ã«ããã®äžã§ãç§ãã¡ã«äœãèµ·ãã£ãã®ããç¥ãããšãã§ããŸãã
ææŠãã ç«ã®äžãèŠãåã«ããŸãã¢ã«ãŽãªãºã ã«ã€ããŠèªåã§èããããšããå§ãããŸãã ããªããç§ãã¡ã®ãªãã·ã§ã³ãããã¯ãŒã«ãªäœããæãã€ããã-ã³ã¡ã³ããæžããŠãã ããã
ãäºçŽ
èšäºã培åºçã«æ€çŽ¢ããªãã£ãããšãäºçŽããŸã-ãã§ã«æ¢ç¥ã®ã¢ã«ãŽãªãºã ãå床éãããããã®åé¡ã解決ããã¢ã«ãŽãªãºã ãé·ãéç¥ãããŠããŸãïŒããããç§ãã¡ãããã¯ããã«å¹æçã§ãïŒã
ç§ãã¡ã®ã¢ã«ãŽãªãºã ã®å®çšçãªå¿çšã¯ã»ãšãã©äžå¯èœã§ãããã¿ã¹ã¯ã¯åŠè¡çãªé¢å¿ã®ããå€ãã®ãã®ã§ãã
æ å ±åé
ããã«é ã«æµ®ãã¶æ¢ç¥ã®çš®é¡ã¯ã3ã€ã®ãã€ã³ããã¹ãŠãåæã«æºããããã§ã¯ãããŸããã次ã«äŸã瀺ããŸãã
- ããã«ãœãŒãïŒããã«ãœãŒãïŒã¯ããã©ã°ã©ã2ããã³3ã«é©åããŸãããOïŒn 2 ïŒã«å¯ŸããŠæ©èœããŸãã
- ã¯ã€ãã¯ãœãŒãã¯ãã€ã³ã2ãš3ãæºãããŸãïŒãã€ã³ã2-ããã€ãã®ã¢ã€ãã¢ã®ç¥èããããŸãïŒãããã€ã³ã1ã«ã€ããŠã¯å¹³åã§OïŒnlognïŒæéã®ã¿ãäžããOã«å¯ŸããŠæ©èœããå ¥åããŒã¿ããããŸãïŒn 2 ïŒã
- ããŒãã®äžŠã¹æ¿ãã¯å¶é1ãš2ãæºãããŸãããæ®å¿µãªããã¡ã¢ãªãžã®ã©ã³ãã ã¢ã¯ã»ã¹ãå¿ èŠã§ãã
- ããŒãžãœãŒãã¯å¶é1ããã³3ã«é©ããŠããŸãããOïŒnïŒè¿œå ã¡ã¢ãªãå¿ èŠã§ãã
- ã€ã³ãã¬ãŒã¹ããŒãžãœãŒãã¯å¶é1ããã³2ã«é©åããŸãïŒ å®å®ãããªãã·ã§ã³ããããŸãã ãé«ã§ãïŒããã¡ã¢ãªã«ã©ã³ãã ã¢ã¯ã»ã¹ããã«å¹æçã«å®è£ ããæ¹æ³ã¯å®å šã«äžæã§ãã
äžå€®å€ãŸãã¯BFPRTã¢ã«ãŽãªãºã ã®äžå€®å€
æåã®ã³ã¡ã³ãã§ã¯ãFordPerfectã®å人ãMedian of Mediansã¢ã«ãŽãªãºã ãææ¡ããŸããããããã¯åºãç¥ãããŠããŸããã§ããã 圌ã®å¥ã®ååã¯ããããçºæããç§åŠè ã®ååã«ç±æ¥ããBFPRTã§ãããããšã«Bã©ã ããããŒãW.ããã€ãããŠã©ã³ãã©ãããããã«ãL.ãªãã¹ãããããŒãE. Tã¢ãªã¢ã³ã ã¢ã«ãŽãªãºã ã¯WikipediaïŒ ru ã en ïŒãããã³Kormenã§èª¬æãããŠããŸãããWikipediaã§ã¯ãã·ã¢èªãšè±èªçãæ¯èŒããŠåããŠãã®æ¬è³ªãç解ã§ããã»ã©äžåšçšã§ãããããå°ã説æããŸãïŒ å ã®èšäºã調ã¹ãªããã°ãªããŸããã§ããïŒ ïŒ ãããŠãHabréã§ã®åœŒã®èª¬æã¯ãŸã ãããŸããã§ããã ã³ãŒã¡ã³ã§ã¯ãã©ã¡ãããšããã°èª¬æã¯æ£åžžã§ãããåŸã§ãã®ã¢ã«ãŽãªãºã ãååšããããšãããããŸããã ãã®ã¢ã«ãŽãªãºã ãæ¢ã«ç¥ã£ãŠããå Žåã¯ããã®èšäºã®äžéšãã¹ãããã§ããŸãã
Median of Mediansã¢ã«ãŽãªãºã ã«ãããææªã®å Žåãç·åœ¢æéã§ä»»æã®é åã®kçªç®ã®é åºçµ±èšãèŠã€ããããšãã§ããŸãã C ++ STLã©ã€ãã©ãªã«ã¯ãåæ§ã®ã¢ã«ãŽãªãºã std :: nth_elementããããŸããããã¯ãQuickselectã¢ã«ãŽãªãºã ã«åºã¥ããŠãããããç·åœ¢æéã®kçªç®ã®é åºçµ±èšãæ€åºããŸãã åŸè ã¯åºæ¬çã«ã¯ã€ãã¯ãœãŒãã§ãåã¹ãããã§ååž°ã®åå²ã1ã€ã ãäžã£ãŠãããŸãïŒQuickselectã®è©³çŽ°ã«ã€ããŠã¯ã ãã¡ããšãã¡ããã芧ãã ãã ïŒã Median of Mediansã¯ãQuickselectã¢ã«ãŽãªãºã ã®ä¿®æ£ã§ããããåå²ãã®æªãèŠçŽ ãéžæããããšã¯ã§ããŸãããææªã®å Žåãäºä¹æéã«ãªããŸãã
ãªãäžå€®å€ã®äžå€®å€ãå¿ èŠãªã®ã§ããïŒ ã¯ãããã¹ãŠãéåžžã«åçŽã§ã-ãã®å©ããåããŠãç·åœ¢æéã§é åã®äžå€®å€ïŒn / 2次統èšïŒãèŠã€ãããã®èŠçŽ ã§é«éãœãŒãã¢ã«ãŽãªãºã ãåå²ããããšãå¯èœã§ãã ããã«ãããOïŒnlognïŒã«å¯ŸããŠå¹³åã§ã¯ãªããææªã®å Žåã«ã¯ã€ãã¯ãœãŒããæ©èœããŸãã
Medians of Mediansã¢ã«ãŽãªãºã ã®èª¬æã å ¥åããŒã¿ïŒé åïŒããšãã°ããªã¹ãã®æåãšæåŸã®èŠçŽ ã§æå®ãããïŒãšæ°å€k-ã©ã®ã¢ã«ãŠã³ãèŠçŽ ãèŠã€ããå¿ èŠããããã
- é åãååã«å°ããå ŽåïŒ5èŠçŽ æªæºïŒ-ãã§ãã§æ³¡ã§ãœãŒãããkçªç®ã®èŠçŽ ãè¿ããŸãã
- é åã®ãã¹ãŠã®èŠçŽ ã5ã€ã®èŠçŽ ã®ãããã¯ã«åå²ããŸãã äžå®å šãªæçµãããã¯ã®å¯èœæ§ã«æ³šæãæã£ãŠããŸããã
- åãããã¯ã§ã¯ãèŠçŽ ãããã«ã§äžŠã¹æ¿ããŸãã
- åãããã¯ã®äžå€®ïŒ3çªç®ïŒã®èŠçŽ ãããµãã¢ã¬ã€ãéžæããŸãã åçŽã«é åã®å é ã«ç§»åã§ããŸãã
- ãããã®[n / 5]èŠçŽ ã®äžå€®å€ã®äžå€®å€ãååž°çã«èµ·åãããããã®äžå€®å€ïŒn / 10çªç®ã®èŠçŽ ïŒãèŠã€ããŸãã ãã®èŠçŽ ã¯ããããèŠçŽ ãšåŒã°ããŸãã
- ãããããã¯ã€ãã¯ãœãŒããšã¯ã€ãã¯ã»ã¬ã¯ãã¢ã«ãŽãªãºã ã§ããç¥ãããŠããåé¢æé ãå®è¡ããŠããŸããåç §èŠçŽ ãããå°ããèŠçŽ ããã¹ãŠé åã®å é ã«ç§»åãããã¹ãŠã®èŠçŽ ãæ«å°Ÿã«ç§»åããŸãã é åã®æåŸã«ããå¯èœæ§ã®ããäžå®å šãªãããã¯ã®èŠçŽ ãèæ ®ãããŸãã åèšã§ã3ã€ã®ãããã¯ãåŸãããŸããèŠçŽ ã¯ãåºæ¬ãããå°ããããããšåçã§ããããã以äžã§ãã
- ã©ã®ãããã¯ã§kçªç®ã®èŠçŽ ãæ¢ãå¿ èŠããããã決å®ããŸãã 2çªç®ã®ãããã¯ã«ããå Žåãããããä»»æã®èŠçŽ ãè¿ããŸãïŒãã¹ãŠåãã§ãïŒã ããã§ãªãå ŽåãèŠçŽ çªå·ãä¿®æ£ã§ãããã®ãããã¯ã®äžå€®å€ã®äžå€®å€ãååž°çã«èµ·åããŸãã3çªç®ã®ãããã¯ã§ã¯ãçªå·kããåã®ãããã¯ã®é·ããæžç®ããå¿ èŠããããŸãã
ããã§äœãèµ·ãã£ãŠãããã®äŸãèŠãŠã¿ãŸãããã é åãããããã®äžå€®å€ãèŠã€ããããšããŸãããïŒ
1ãã27ãŸã§ã®27ã®ç°ãªãçªå·ããããŸããé£ç¶ããŠ14çªç®ã®èŠçŽ ãæ¢ããŠããŸãã èŠçŽ ãé·ã5ã®ãããã¯ã«åå²ããåãããã¯å ã®æ°åã䞊ã¹æ¿ããŸãã
åãããã¯ã®äžå€®å€ã¯é»è²ã§åŒ·èª¿è¡šç€ºãããŸãã ããããé åã®å é ã«ç§»åããã¢ã«ãŽãªãºã ãååž°çã«å®è¡ããŠããã®äžã®äžå€®å€ãæ€çŽ¢ããŸãã
ååž°ã®å éšã§äœãèµ·ããããæžãçããŸããã1ã€ã¯ã£ããããŠããããšã¯ã12ãæãŸããäžå€®å€ã«ãªãããšã§ãã
ãã®æ°å€12-äžå€®å€ã®æ¯æèŠçŽ ãŸãã¯äžå€®å€-ã¯ã次ã®é¡èãªç¹æ§ãæã£ãŠããŸãã æ°æã®åçã«æ»ã£ãŠã次ã®ããã«ãããã¯ã粟ç¥çã«åãããŠã¿ãŸãããã
ãã¹ãŠã®åã¯äžå€®ã®èŠçŽ ã§ãœãŒããããããã«ååã®èŠçŽ ããœãŒããããŸãã æ¯æèŠçŽ ã®å·Šäžã«ããèŠçŽ ã®çŽ30ïŒ ïŒæ£ç¢ºã«ã¯3 / 10n + OïŒ1ïŒïŒã¯ããããã倧ãããªãããšãããããŸãã åæ§ã«ããµããŒãèŠçŽ ã®å³äžã«ããèŠçŽ ã®çŽ30ïŒ ã«ã€ããŠã¯ããã以äžã§ãã ã€ãŸããåé¢æé ãå®è¡ãããšããã¹ãŠã®èŠçŽ ã®çŽ30ïŒ ãå¿ ç¶çã«æ¯æèŠçŽ ã®å·ŠåŽã«ãçŽ30ïŒ ãå³åŽã«ãªããŸãã
å®éãããããªäžæ£ç¢ºãããããŸãã幞éãªããšã«ãåç §èŠçŽ ã«çããèŠçŽ ã1ã€ã ãååšãããšããäºå®ããããŸããã ãã®ãããªèŠçŽ ãå€æ°ããå Žåããããã¯ãã¹ãŠãããã¯å šäœã圢æãããµããŒãèŠçŽ ãæ£ç¢ºã«ã©ãã«åãŸããã¯æ確ã§ã¯ãããŸããã ããããããã¯æ¬åœã«éèŠã§ã¯ãããŸããã æ¯æèŠçŽ 以äžã®èŠçŽ ã¯å°ãªããšã30ïŒ ã§ããããšãããã£ãŠããŸããã€ãŸããæ¯æèŠçŽ ããå³å¯ã«å°ããèŠçŽ ã¯70ïŒ ä»¥äžã§ãã åæ§ã«ããµããŒãèŠçŽ ãããå³å¯ã«å€§ããèŠçŽ ã70ïŒ ä»¥äžã§ãã ãããã£ãŠãäžèšã®ã¢ã«ãŽãªãºã ã®èª¬æããã®æåãš3çªç®ã®ãããã¯ã®ãµã€ãºã¯ãåžžã«7 / 10n + OïŒ1ïŒä»¥äžã®é·ããæã¡ãŸãïŒ
äŸã®åæãç¶ããŸãã åé¢æé ã®åŸã14çªç®ã®èŠçŽ ã3çªç®ã®ãããã¯ã«ããããšãæããã«ãªãããããã®ã¢ã«ãŽãªãºã å šäœãååž°çã«å®è¡ããŸãããçŸåšã¯2çªç®ã®èŠçŽ ãæ¢ããŠããŸãã
ã¢ã«ãŽãªãºã ã®è€éãã¯äœã§ããïŒ
TïŒnïŒããé·ãnã®é åã«å¯ŸããMedian of Mediansã¢ã«ãŽãªãºã ã®ææªã®å Žåã®æ°æŒç®ãšããŸãã åã¹ãããã§ãã¢ã«ãŽãªãºã ã¯èªèº«ã2åååž°çã«2ååŒã³åºããŸãã æåã¯ãé·ããn / 5 + OïŒ1ïŒåã®èŠçŽ ã®é åã§äžå€®å€ã®äžå€®å€ãèŠã€ããããšã§ãã 2åç®-æ¢çŽ¢ç©ºéãçž®å°ããŸãããææªã®å Žåãé åã®ãµã€ãºã¯7 / 10n + OïŒ1ïŒã«æžå°ããŸãã ä»ã®ãã¹ãŠã®æäœã«ã¯ç·åœ¢æéãå¿ èŠã§ãã åèšã¯æ¯çãååŸããŸãïŒ
TïŒnïŒ= TïŒ2 / 10nïŒ+ TïŒ7 / 10nïŒ+ Cnãããã§Cã¯å®æ°ã§ãã
ãã®é¢ä¿ãæ¡åŒµããŸãããã
TïŒnïŒ= Cn +ïŒ 2/10 + 7/10 ïŒCn +ïŒ 2/10 + 7/10ïŒ ïŒ 2/10 + 7/10 ïŒCn + ... = Cn * â i =0..â ïŒ 9/10ïŒ i = 10Cn = OïŒnïŒ
ãããïŒ ã¢ã«ãŽãªãºã ã«ã¯ç·åœ¢ã®è€éãããããŸãïŒ
Median of Mediansã¯ãååž°ã䜿çšããŠãªã¹ãã«ç°¡åã«å®è£ ã§ããŸããããã«ãããOïŒlognïŒã¡ã¢ãªã䜿çšããåäžãªã³ã¯ãªã¹ãã§ã®OïŒnlognïŒã®äžŠã¹æ¿ããä¿èšŒãããŸãã
ã³ãŒã
ããã§ååž°ãåãé€ããŸãããã
ãã©ããã¯ã€ãã¯ãœãŒã
å§ããããã«ãå®éã«ã¯ã¯ã€ãã¯ãœãŒãããååž°ãåé€ããŸãããã ãããè¡ãæ¹æ³ã¯å®å šã«æããã§ã¯ãªãããããã®ã»ã¯ã·ã§ã³ã§ã¯ãã®æ¹æ³ã説æããŸãã
ãã®ã»ã¯ã·ã§ã³ã§ã¯ãComdade FordPerfectãgamedev.ruãã©ãŒã©ã ã§ææ¡ããã¢ã€ãã¢ã«ã€ããŠèª¬æããŸãïŒå®éããã®èšäºã®ãã¹ãŠã®ã¢ã€ãã¢ã¯ç§ã®ãã®ã§ã¯ãããŸãã-ã¡ããã©æçš¿ããŸããïŒã ã¢ã€ãã¢ã®åºæã¯äžæã§ãGoogleã¯ã»ãšãã©ã®éšåã§æ²é»ããã¹ã¿ãã¯ãããªãé »ç¹ã«ãšãã¥ã¬ãŒããããããããå埩ã¯ã€ãã¯ãœãŒããžã®å€ãã®ãªã³ã¯ãæäŸããŸãïŒãã ããåæ§ã®ã¢ã€ãã¢ã®è°è«ããããŸããïŒã ãOïŒ1ïŒã¡ã¢ãªãåããã¯ã€ãã¯ãœãŒããã¿ã¹ã¯ã«ã€ããŠèããæéã ãFlat quick sortããšããååãèªäœã§ããããããããã®ã¢ã«ãŽãªãºã ã¯å¥ã®ååã§ç¥ãããŠããŸãã
éåžžã®ååž°ã¯ã€ãã¯ãœãŒããã©ã®ããã«æ©èœããããæãåºããŸãããã å ¥åããŒã¿ïŒããšãã°ãåçŽã«æ¥ç¶ããããªã¹ãã®éå§èŠçŽ ãšçµäºèŠçŽ ã®2ã€ã®å埩åã«ãã£ãŠæå®ãããé åã
- 1ã€ã®ãã¹ããã§ãã¯ã€ã³ããŸããé åãæ¢ã«ãœãŒããããŠããå Žåãå®è¡ããããšã¯ãããŸãã-çµäºããŸãã
- åé¢æé ã®èŠçŽ ïŒããããïŒãéžæããŸã-éåžžã¯ã©ã³ãã ã§ããããã®å Žåã¯ãMedian of Mediansã¢ã«ãŽãªãºã ã䜿çšããŠäžå€®å€ãéžæããŸãã
- åé¢æé ãäœæããŸã-3ã€ã®ãããã¯ãååŸããŸãããããããããå°ããèŠçŽ ã 圌ã«çããèŠçŽ ; èŠçŽ ã倧ãããªããŸãã
- æåãš3çªç®ã®ãããã¯ã«å¯ŸããŠååž°çã«ã¯ã€ãã¯ãœãŒããå®è¡ããŸãã
ååž°äžã«èŠããŠããå¿ èŠãããæ å ±ã¯ã3çªç®ã®ãããã¯ã®å§ãŸããšçµããã§ãã
次ã®ããšã«æ³šæããŠãã ãããæåã®ãããã¯ã®èŠçŽ ã¯2çªç®ã®ãããã¯ã®èŠçŽ ãããå°ããã2çªç®ã®ãããã¯ã®èŠçŽ ã¯3çªç®ã®ãããã¯ã®èŠçŽ ãããå°ãããªããŸãã
èãæ¹ã¯æ¬¡ã®ãšããã§ããåãããã¯ã®æ倧èŠçŽ ããããã¯ã®å é ã«ç§»åããŸãããã ãã®åŸã次ã®ãããã¯ãã©ãããå§ãŸãããæ確ã«æ±ºå®ã§ããŸãïŒ ãããè¡ãã«ã¯ããããã¯ã®å é ããå³å¯ã«å€§ããèŠçŽ ã«åºäŒããŸã§ç§»åããŸãã次ã®ãããã¯ã®å é ãéç¥ããŸãïŒ
ããã§ãã¯ã€ãã¯ãœãŒãã¢ã«ãŽãªãºã ã次ã®ããã«æžãæããããšãã§ããŸãã
- ãã€ã³ã¿ãŒXãšYãäœæããŸãããã€ã³ã¿ãŒXãé åã®å é ãæãããã€ã³ã¿ãŒYããã®æ«å°Ÿãæãããã«ããŸãã ãŸããçŸåšã®ãããã¯ã®çµãããæããã€ã³ã¿ãŒZãäœæããŸãã æåã¯ãZ = Yã§ãã
- 次ã®ã¢ã¯ã·ã§ã³ãééãªãå®è¡ããŸãã
- çŸåšã®XZãããã¯ãæ¢ã«ãœãŒããããŠããå Žåã次ã®ãããã¯ãæ¢ããŸãã XãZã«ç¶ãèŠçŽ ã«ç§»åããŸããXã移åã§ããªãå ŽåãZ = Yã§ãããããã«ãŒããçµäºããŸãã ããã§ãXãæãèŠçŽ ããã倧ãããXã®åŸã®æãè¿ãèŠçŽ aãæ¢ããŸãããªãå Žåã¯ãZ = Yãå®è¡ããŸãã
- ã¯ã€ãã¯ãœãŒãã®éåžžã®ã¢ã¯ã·ã§ã³ãå®è¡ããŸããåé¢ããèŠçŽ ã®éžæãšåé¢èªäœã§ãã 3ã€ã®ãããã¯ãååŸããŸãã
- 3çªç®ã®ãããã¯ã®ãããã¯åãè¡ããŸãããã®äžã®æ倧èŠçŽ ãæ¢ããŠãå é ã«ç§»åããŸãã
- Zãæåã®ãããã¯ã®æåŸã«ç§»åããŸãã
次ã«ãäŸã䜿çšããŠãã®ã¢ã«ãŽãªãºã ãæ€èšããŸãã
ç§ã¯ãã§ã«ãã®é åãèŠãŸãã...ãã€ã³ã¿ãŒXãYãZãå ¥ããŸãããïŒ
XZãããã¯ã¯ãœãŒããããŸããã 次ã«ãäžå€®å€ãèŠã€ããŸãã
äžå€®å€æ€çŽ¢æé ã¯ãæãå¥åŠãªæ¹æ³ã§èŠçŽ ãã·ã£ããã«ããäžå€®å€èªäœãæåã«æ®ããšä»®å®ããŸãïŒäŸãšããŠãå®è£ ã¯ãäžå€®å€ã§ããèŠçŽ ã«å埩åãè¿ãå ŽåããããŸãïŒã ã§ã¯ãåé¢æé ãå®è¡ããŸãããã
ããã¯3ãããã¯ã«ãªããŸããã æåŸã®ãããã¯ããããã¯ããZãæåã®ãããã¯ã®æåŸã«ç§»åããŸãã
ä»ãç§ãã¡ã¯æåããå§ããŸãã çŸåšã®XZãããã¯ã¯ãœãŒããããŠããªãããããã®äžã®äžå€®å€ãæ¢ããŠããŸãã
åé¢æé ãå®è¡ããŸãã
3çªç®ã®ãããã¯ããããã¯ããZãæåã®ãããã¯ã®æåŸã«ç§»åããŸãã
ããäžåºŠãXZãèŠãŠãã ããã
ã©ãããŒã§ãïŒ ãããã¯ã¯ãœãŒããããŠããããããã®ãŸãŸã«ããŠæ¬¡ã®ãããã¯ãæ¢ãããšãã§ããŸãã ãã€ã³ã¿ãŒXãšZã¯æ¬¡ã®ããã«ç§»åããŸãã
ããã¯åã®ã¹ãããã®2çªç®ã®ãããã¯ã§ãããããçªç¶ããã®ãããã¯ããœãŒããããŸãã 次ã®ãããã¯ãæ¢ããŠããŸãïŒ
泚æã確èªããŸã-æ®å¿µãªãããä»åã¯å¹žéã§ã¯ãªãã£ãã®ã§ãæé ããå¿ èŠããããŸãã äžå€®å€ãèŠã€ããŠãããåé¢æé ãå®è¡ããŸãã
次ã«ããããã¯[8,9]ã«ç§»åãããœãŒããããŸãããã®ãããXãšZã¯ãããã¯[10]ã«ç§»åããããããœãŒããããŸãããã®åŸãã¢ã«ãŽãªãºã ã¯ãããã¯[13ã11ã12]ãèæ ®ããŸãã ã ã¢ã¬ã€ã®åŸåã®ãœãŒãåæã¯ãèªè ãåå¥ã«å®è¡ããããšãææ¡ããŸãã
ã³ãŒã
OïŒ1ïŒã®è¿œå ã¡ã¢ãªãåããäžå€®å€ã®ããããã®äžå€®å€
æ®å¿µãªãããMedian of Mediansã§ã¯ãæ倧èŠçŽ ã䜿çšããŠãã©ããã¯ã€ãã¯ãœãŒãã§ãããã¯ãèå¥ãããªã©ã®ããªãã¯ã¯æ©èœããŸãããããã¯ãæ¯åé åã®èŠçŽ ãäžæ確ã«æ··åšããŠããããã§ãã ããã§ã¯ãå¥ã®ãã©ãŒã«ã¹ã䜿çšããŸãã
å®éãä¿èšŒãããOïŒnlognïŒã«å¯ŸããŠè¿ éãªãœãŒããå®è¡ããããã«ãåé¢æ®µéã®æ£ç¢ºãªäžå€®å€ãèŠã€ããå¿ èŠã¯ãããŸããã è¿äŒŒå€ãèŠã€ããã ãã§ååã§ãã ç¹å®ã®C <1ã«ã€ããŠãåé¢æ®µéåŸã®æåãš3çªç®ã®ãããã¯ãCnãè¶ ããªãããšãä¿èšŒããå ŽåãOïŒnlognïŒã®ã¯ã€ãã¯ãœãŒããæ©èœããŸãã C = 0.99ã§ãã
ãããã£ãŠãã¡ãã£ã¢ã³ã®äžå€®å€ãå€æŽããŠããšã©ãŒK = OïŒlog 2 nïŒã®äžå€®å€ãèŠã€ããŸãã ã€ãŸããã·ãªã¢ã«çªå·ãn / 2-K / 2ãn / 2 + K / 2ã®ç¯å²ã«ããèŠçŽ ãèŠã€ãããŸãã Kã¯å¯Ÿæ°ã®æ¬¡æ°ã§ãããããã»ã°ã¡ã³ã[n / 2-K / 2ãn / 2 + K / 2]ãååšããïŒå ·äœçã«ã¯ïŒnãèŠã€ããã®ã¯ç°¡åã§ããããšãã°ã1 / 4nãš3 / 4nã®éã§ãã ãã¹ãŠã®å°ããnã«ã€ããŠãããã«ã ãã§ãœãŒãã§ããŸãã
ãªãK = OïŒlog 2 nïŒã§ããïŒ ã¯ããKé åèŠçŽ ã䜿çšããŠãã¹ã¿ãã¯ã«å¿ èŠãªãã¹ãŠã®æ å ±ãæ ŒçŽããŸãïŒãããFordPerfectã®ä»²éã§ãïŒã ååž°ã¬ãã«ã¯OïŒlognïŒã§ãããããããã«ã€ããŠãOïŒlognïŒãããããšã«OïŒ1ïŒã®æ°å€ãæ ŒçŽããå¿ èŠããããŸãã ãããŠãæ®ãã®NKèŠçŽ ã®äžã§ã¯ã€ãã¯ãœãŒãã®äžå€®å€ãèŠã€ããŸãã
åãããã¯ãé åã®2ã€ã®é£ç¶ããç°ãªãèŠçŽ ã«ãã£ãŠè¡šãããŸãã ãããã®æåã®å€ã2çªç®ã®å€ããå°ããå Žåããããã¯ç¶æ 0ãæ ŒçŽããããã§ãªãå Žåã¯-1ïŒãŸãã¯ãã®éïŒãæ ŒçŽããŸãã 解決ããå¿ èŠãããæåã®ã¿ã¹ã¯ã¯ãé åã®ç°ãªãèŠçŽ ã®K / 2ãã¢ãèŠã€ããããŸãå€ãã®ãã¢ãèŠã€ãããªãå Žåã®å¯ŸåŠæ¹æ³ãç解ããããšã§ãã
ããã¯éåžžã«ç°¡åã§ãã å埩åXãšYãé åã®æåã®èŠçŽ ãæãããã«ããŸãã XãšçãããªãèŠçŽ ãèŠã€ãããŸã§Yãåæ¹ã«ç§»åããŸãããããèŠã€ãã£ãããXãåæ¹ã«ç§»åããXãšYãæãèŠçŽ ã亀æããXãåæ¹ã«å床移åããŸãïŒ+å°ããå ŽåãåŒãç¶ãåŠçããå¿ èŠãããå Žå-Yãåæ¹ã«ç§»åããŸãXã«çŽé¢ããã ãããŠãK / 2ãã¢ãèŠã€ãããŸã§ã Yããã§ã«é åã®çµããã«éããK / 2ãã¢ããŸã èŠã€ãããªãå Žåã¯ã©ããªããŸããïŒ ããã¯ãXããYãŸã§ã®ãã¹ãŠã®èŠçŽ ãåãã§ããããšãæå³ããŸãïŒ ïŒãã®äžå€åŒãã¢ã«ãŽãªãºã å šäœã®å®è¡äžã«ä¿åãããããšã確èªããã®ã¯éåžžã«ç°¡åã§ãïŒã 次ã«ããµããŒãèŠçŽ ãšããŠããããã®èŠçŽ ã®1ã€ãããã«éžæã§ããŸãã K <n / 2ãéžæããå Žåããã®ãµããŒãèŠçŽ ã¯æ£ç¢ºãªäžå€®å€ã«ãªããŸãã
ããŠã質åã¯æ¬¡ã®ãšããã§ããã¹ã¿ãã¯ãæäœãããšãã¢ã«ãŽãªãºã ã®æŒžè¿çãªåäœãå£ããŸããïŒ ããã¯éåžžã«è¯ã質åã§ããäžèŠãããšãååž°ããªãŒã®é ç¹ã®é åºã¯OïŒnïŒã§ãããåé ç¹ã«å¯ŸããŠã¹ã¿ãã¯ã§OïŒlog 2 nïŒæäœãå¿ èŠã ãšæãããããã§ãã Median of Mediansã®æŒžè¿çæåã¯OïŒnlog 2 nïŒïŒããã³ã¢ã«ãŽãªãºã å šäœã®OïŒnlog 3 nïŒïŒã«æªåããŠããŸããïŒ ããã§ã¯ãã¹ãŠãå°ãè€éã§ãã
ããªãŒå ã®é ç¹ã®æ£ç¢ºãªæ°ãèšç®ããã«ã¯ã次ã®ç¹°ãè¿ãã解決ããå¿ èŠããããŸãã
NïŒnïŒ= NïŒn / 5ïŒ+ NïŒ7N / 10ïŒ+ 1
n <Cã®å ŽåãNïŒnïŒ= 1
äžèšãšäŒŒããããªãã®ãèŠãããŸãããCnã1ã«çœ®ãæãããšãååž°ã®èšç®ãããââé£ãããªããŸãã Acra-Bazziæ¹åŒãå©ãã«ãªããŸãã ååž°ã¯ãã¹ãŠã®æ¡ä»¶ã«é©åãã察å¿ãããã¹ãŠã®é åã®åŸãé ç¹ã®æ°NïŒnïŒãOïŒn 0.84 ïŒïŒããæ£ç¢ºã«ã¯ÎïŒn 0.839780 ... ïŒïŒãšããŠå¢å ããããšãããããŸã ã ã¢ã«ãŽãªãºã ã®ç·æéè€é床ã¯OïŒn + n 0.84 log 2 nïŒ= OïŒnïŒã§ãã
ã¢ã«ãŽãªãºã ã®ãã以äžã®ã¹ãã«ã¯äžèŠã§ãããšèããŠããŸãããã®èšäºã®åã®ç« ã®ããããã§èª¬æããããã®ãå®è£ ããã ãã§ãã ã³ãŒããããã«ç¢ºèªããããšããå§ãããŸãã ç»åããããŸãããã¢ã«ãŽãªãºã ããŸã£ããæ©èœããªãããã«ã¯ãé åå ã«ããªãå€ãã®èŠçŽ ãå¿ èŠã§ãã ã©ã£ã¡ïŒ 詳现ã«ã€ããŠã¯ã以äžãã芧ãã ããã
ææ¡ãããã¢ã«ãŽãªãºã ã¯ã©ã®çšåºŠéå®çšçã§ããïŒ èšç®ã¯æ¬¡ã®ãšããã§ãã
å®éã®äžå€®å€ãã1 / 4n以äžã®åå·®ãååŸãããšããŸãïŒã€ãŸããK <n / 2ïŒã 次ã«ã3 [logn]ååž°ã¬ãã«ã§ã¹ã¿ãã¯ããã³ããŒã§æã€å¿ èŠããããŸãïŒããã§ãlogã¯2é²æ°ã§ãïŒ3/4ïŒ 3 <0.5ã§ããã[x]ã¯æ°å€xãæãè¿ãæŽæ°ã«åãäžããŸãïŒã ååž°ã¬ãã«ããšã«2 [logn]ããããå¿ èŠã§ããçŸåšã®é åã®é·ããçŸåšæ¢ããŠããèŠçŽ ïŒãã®æ°ã¯åžžã«[logn] -1ãããã«åãŸããŸãïŒããã³ãã©ããŒãµã«ããªãŒã®ãã©ããŒãµã«é åºãç¶æããããã®ãã1ããããæ ŒçŽããå¿ èŠããããŸãïŒå¿ èŠã§ãïŒã©ã®ååž°åå²ããæ»ã£ãããæãåºããŠãã ããïŒã åãããã«ã¯2ã€ã®èŠçŽ ããããã¹ã¿ãã¯ããšã«åèš12 [logn] 2ã€ã®èŠçŽ ããããŸãã
ããã§æ¹çšåŒã解ããŸãïŒ12 [logn] 2 <n / 2ãŸãã¯24 [logn] 2 <nã nãèŠã€ããå¿ èŠããããŸãïŒn> = nã®å ŽåïŒ24 [logn] 2 <nã ãã®n 'ã¯3500ã®ãªãŒããŒã§ããã€ãŸããn <3500ã®å Žåãããã«ã§ãœãŒãããå¿ èŠããããŸãã
Kãåžžã«n-1500ãè¶ ããªãnã®å¶éãã€ãŸããn <1500ã®å ŽåããœãŒãã¯æ©èœããŸããïŒã¹ã¿ãã¯ããšãã¥ã¬ãŒãããã®ã«ååãªèŠçŽ ããããŸããïŒãããã§ã¯ããããããšãªãããã«ã䜿çšããå¿ èŠããããŸãã ãã ããå®æ°ãããããšããããããã®æšå®å€ã¯æ¹åãããå¯èœæ§ããããŸãã
ã³ãŒã
ã³ãŒã
èšäºå šäœã®ã³ãŒããžã®ãã¹ãŠã®ãªã³ã¯ã1ãæã§ïŒ
- ã¯ã€ãã¯ãœãŒã+äžå€®å€ã®äžå€®å€ ïŒä¿èšŒOïŒnlognïŒãOïŒlognïŒã®è¿œå ã¡ã¢ãªïŒ
- ãã©ããã¯ã€ãã¯ãœãŒã+äžå€®å€ã®äžå€®å€ ïŒä¿èšŒOïŒnlognïŒãOïŒlognïŒã®è¿œå ã¡ã¢ãªïŒ
- ãã©ããã¯ã€ãã¯ãœãŒã+äžå€®å€ã®ããããã®äžå€®å€ ïŒä¿èšŒOïŒnlognïŒãOïŒ1ïŒè¿œå ã¡ã¢ãªïŒ
èªã
- gamedev.ru ã®ã¢ã«ãŽãªãºã ã®èª¬æã
- ãŠã£ãããã£ã¢ã®ã¡ãã£ã¢ã³ã®äžå€®å€ïŒ en ã ru ïŒã
- Quickselectã«ã€ããŠã¯ã ãã¡ããšãã¡ããã芧ãã ãã ã
- ãŠã£ãããã£ã¢ã®Acra-Bazziã¡ãœãã ã
- Manual BlumãRobert W. FloydãVaughan PrattãRonald L. Rivestãããã³Robert E. Tarjanã éžæã®æéç¯å² ã ïŒpdfãengïŒ
- S.ãããã£ã¢ããDãã«ã³ãã³ãDãã«ã¿ã©ããGãã·ã³ã³ããã£ã è¿äŒŒäžå€®å€éžæåé¡ã®å¹ççã¢ã«ãŽãªãºã ã ïŒpdfãengïŒ-é«éã®è¿äŒŒç¢ºççäžå€®å€äžå€®å€