Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
簡潔データ構造輪講資料(順列)
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Sho Iizuka
June 19, 2017
Science
9.5k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
簡潔データ構造輪講資料(順列)
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
8.2k
Pythonにおける日本語処理
arosh
1
2.2k
FM-index による全文検索
arosh
0
57
円と円の外接線の求め方
arosh
0
92
円と円の交点の求め方
arosh
0
54
Other Decks in Science
See All in Science
因果探索の発展と展望
sshimizu2006
2
1.1k
知能とはなにか -ヒトとAIのあいだ-
tagtag
PRO
0
190
presen_司法書士学員会.pdf
tagtag
PRO
1
110
GKE上でオセロの強化学習やってみた
akasan
0
110
Massey Ratings for Match Outcome Prediction in Table Tennis: Evidence of Greater Stability than the ITTF World Ranking
konakalab
0
150
20260410_SystemsThinking
takusamar
1
160
因果推論と機械学習
sshimizu2006
1
1.4k
データベース15: ビッグデータ時代のデータベース
trycycle
PRO
1
570
Utiliser Bitcoin sans Internet
rlifchitz
0
380
明治薬科大学講義_ビッグデータ解析を支えるデータベース技術とクラウドコンピューティング
ktatsuya
1
180
機械学習 - pandas入門
trycycle
PRO
0
710
SAT ソルバーの仕組みと制約ソルバーへの応用
tsoh
1
370
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
360
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
910
Documentation Writing (for coders)
carmenintech
77
5.5k
The untapped power of vector embeddings
frankvandijk
2
1.9k
Between Models and Reality
mayunak
4
460
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Code Reviewing Like a Champion
maltzj
528
40k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
410
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
Ruling the World: When Life Gets Gamed
codingconduct
0
330
Visualization
eitanlees
152
17k
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