Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
簡潔データ構造輪講資料(順列)
Search
Sho Iizuka
June 19, 2017
Science
9.1k
1
Share
簡潔データ構造輪講資料(順列)
Compact Data Structures: A Practical Approach の Chapter 5: Permutations の輪講資料です。
Sho Iizuka
June 19, 2017
More Decks by Sho Iizuka
See All by Sho Iizuka
半年前の自分に教えたい systemd のハマりどころ
arosh
19
18k
Osaka.Stan#5 LT プログラミングコンテストのデータを分析した話
arosh
1
7.8k
Pythonにおける日本語処理
arosh
1
2.2k
FM-index による全文検索
arosh
0
51
円と円の外接線の求め方
arosh
0
76
円と円の交点の求め方
arosh
0
45
Other Decks in Science
See All in Science
コンピュータビジョンによるロボットの視覚と判断:宇宙空間での適応と課題
hf149
1
620
検索と推論タスクに関する論文の紹介
ynakano
1
190
フィードフォワードニューラルネットワークを用いた記号入出力制御系に対する制御器設計 / Controller Design for Augmented Systems with Symbolic Inputs and Outputs Using Feedforward Neural Network
konakalab
0
120
ITTF卓球世界ランキングのポイント比を用いた試合結果予測モデルの性能評価 / Performance evaluation of match result prediction models using the point ratio of the ITTF Table Tennis World Ranking
konakalab
0
110
Conversation is the New Dashboard: 属人性を排除する第4世代BIツールの勢力図
shomaekawa
1
530
アクシズを探せ! 各勢力の位置関係についての考察
miu_crescent
PRO
1
240
Text-to-SQLの既存の評価指標を問い直す
gotalab555
1
200
【論文紹介】Is CLIP ideal? No. Can we fix it?Yes! 第65回 コンピュータビジョン勉強会@関東
shun6211
5
2.4k
因果推論と機械学習
sshimizu2006
1
1.1k
共生概念の整理と AIアライメントの構想
hiroakihamada
0
180
「遂行理論の未来」(松島斉教授最終講義記念セッションの発表資料)
shunyanoda
0
850
データベース01: データベースを使わない世界
trycycle
PRO
1
1.2k
Featured
See All Featured
The Mindset for Success: Future Career Progression
greggifford
PRO
0
310
Into the Great Unknown - MozCon
thekraken
40
2.4k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
230
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
340
SEO for Brand Visibility & Recognition
aleyda
0
4.5k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
320
GitHub's CSS Performance
jonrohan
1032
470k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
480
Code Reviewing Like a Champion
maltzj
528
40k
A better future with KSS
kneath
240
18k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
260
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Transcript
Chapter 5: Permutations Compact Data Structures: A Practical Approach (Gonzalo
Navarro) 発表者:飯塚 1
発表の流れ 2 1. 順列 [1, ] の最悪エントロピーの評価 ➡ 順列の保存は log
bits でほとんど最適 2. Inverse *+() を実現する簡潔順列 ➡ 1 + log + () bits の空間計算量で 1/ の時間計算量を実現 ( > 0) 3. Power 5() を実現する簡潔順列 ➡ 任意の について *+() と同様の時間・空間計算量 内部的には *+() の簡潔順列を利⽤して実現される
順列 [1, ] の最悪エントロピーの評価 3 • 順列 [1, ]:1, 2,
…, n を並べ替えた配列 • ⼤きさ の順列は ! 種あるので ℋ9: = log = log ! a. ≥ 1 のとき ! ≤ ? より ℋ9: ≤ log ? = log b. log ! = log ∏ ? 5A+ = ∑ log ? 5A+ Jensen の不等式 ∑ 5 ? 5A+ ≤ + ? ∑ 5 ? 5A+ が使える E log ? 5A+ ≤ log 1 E ? 5A+ = log 1 ⋅ 1 2 + 1 = (log + 1 − 1) = log + 1 − Θ() c. Stirling の近似を使うと log ! = log − Θ() 各要素 log bits の配列 (Section 3.1) に保存するだけで ほとんど最適 ➡ 有⽤な機能という付加価値を付ける
実現したい有⽤な機能 4 • *+ : = となる を⾒つける • 5():
… … のように を 回適⽤したとき の遷移先を求める • 1 + log + () bits のスペースで 1/ の時間計算量を実現 ( > 0) • log + log ではないから succinct ではない? ➡ = 1/ log とすれば log + bits のスペースで log の時間計算量
5.1 Inverse Permutations 5 【⽬的】*+ : = となる を⾒つける a.
あらかじめ *+ を持っておくと時間計算量 1 ➡ 補助領域が log bits … log が達成できない b. + = () ,O = + , … を繰り返して = となる を⾒つけたらストップ ➡ 時間計算量が () … は⼤きい b. をベースに⾼速化するためのアイデア 1. cycle decomposition 2. shortcut
cycle decomposition 6 1 2 3 4 5 6 7
8 9 10 11 12 () 10 7 3 5 8 1 11 12 4 6 9 2 5 8 12 2 7 9 4 11 10 6 1 3
shortcut 7 5 8 12 2 7 9 4 11
Inverse *+ の計算 1. 基本的には順列の⽅向に進む 2. 逆向きのショートカットがあったら1度だけ使う 3. = となる を⾒つけたらストップ 時間計算量 : パラメータ 以上の間隔が空かないように 逆向きのショートカットを⽤意
shortcut の格納 8 5 8 12 2 7 9 4
11 1 2 3 4 5 6 7 8 9 10 11 12 () 10 7 3 5 8 1 11 12 4 6 9 2 0 1 0 0 0 0 0 1 1 0 0 0 8 9 2 :ショートカットの有無 :ショートカット先 は左詰めにして の rank で アクセスする
空間計算量と時間計算量 9 • , 元の順列: log bits • , shortcut
の有無: n bits の bit vector。constant time の rank が必要。4.2.2 の⽅法で + bits • , shortcut 先:サイクルの⻑さを としたとき 個々のサイクルは / 個のショートカットを持つから の要素数は O? WX+ を超えない(←サイクル⻑が + 1 の場合) よって O WX+ log bits • = O WX+ とおくと 1 + log + + () bits • = 1/ log とすれば log + bits のスペースで = 1/ = log の時間計算量
5.2 Powers of Permutations 10 サイクル順に要素を並べた配列を作ると Power は簡単に計算できる + …
[5, 8, 12, 2, 7, 11, 9, 4] O … [10, 6, 1] Z … [3] 5 8 12 2 7 9 4 11 10 6 1 3
Power の計算例 11 • + … [5, 8, 12, 2,
7, 11, 9, 4] • O … [10, 6, 1] • Z … [3] O[(12) を計算したい 1. 12 は + の 3 番⽬の要素である 2. + 3 − 1 + 20 mod + + 1 = + 22 mod 8 + 1 = 9 *+(10) を計算したい 1. 10 は O の 1 番⽬の要素である 2. O 1 − 1 − 1 mod O + 1 = O −1 mod 3 + 1 = 1 *+ のデータ構造は不要だった? ➡ 5 の実装に必要
格納⽅法 (1) 12 + … [5, 8, 12, 2, 7,
11, 9, 4] O … [10, 6, 1] Z … [3] • :+ , O , … を並べた配列。 log bits • :+ , O , … の終端の位置が 1 になる bit vector。 pred と succ (Section 4.5.2) を使ってサイクル⻑を 求める ※ 元の順列 の格納はもはや不要 1 2 3 4 5 6 7 8 9 10 11 12 5 8 12 2 7 11 9 4 10 6 1 3 0 0 0 0 0 0 0 1 0 0 1 1
格納⽅法 (2) 13 • これだけでは「 上での の出現位置」を答えるのに かかってしまう • そこでポインタ
を⽤意して 1 で計算可能にする 5 8 12 2 7 11 9 4 10 6 1 3 0 0 0 0 0 0 0 1 0 0 1 1 1 2 3 4 5 6 7 8 9 10 11 12
格納⽅法 (3) 14 • に ⌈log ⌉ bits, に ⌈log
⌉ bits, に + () 必要 • これでは 2 log + () bits 必要で簡潔にならない • 実は は不要 5 8 12 2 7 11 9 4 10 6 1 3 0 0 0 0 0 0 0 1 0 0 1 1 1 2 3 4 5 6 7 8 9 10 11 12
格納⽅法 (4) 15 • に Section 5.1 の⼿法を適⽤して *+ を計算可能にする
• の 番⽬の要素は *+() で計算可能 • よって に 1 + log + + () bits, に + () bits • = 1/ log のとき全体で log + bits 5 8 12 2 7 11 9 4 10 6 1 3 0 0 0 0 0 0 0 1 0 0 1 1 1 2 3 4 5 6 7 8 9 10 11 12
計算例 16 O[(12) を計算したい 1. 12の 上での位置は 12 = 3
2. , 3 = 0, , 3 = 8 よりサイクル⻑は 8 3. 3 − 1 + 20 mod 8 + 1 = 7, *+ 7 = 9 5 8 12 2 7 11 9 4 10 6 1 3 0 0 0 0 0 0 0 1 0 0 1 1 1 2 3 4 5 6 7 8 9 10 11 12