Slide 16
Slide 16 text
N ݸͷத͔Β K ݸબͿํ๏: deterministic
O(K log K)
▶ ࣍ͷํ๏Ͱ deterministic O(K log K) ΛୡͰ͖Δ
N ݸͷத͔Β K ݸબͿํ๏
1: t ← N − K + 1, d ← ͞ K ͷྻ
2: for i = 0, . . . , K − 1 :
3: r ← rand(0, t + i)
4: if r < t : d[i] ← r
5: else d[i] ← d[r − t]
6: end if
7: end for
8: d Λঢॱιʔτ͢Δ
9: for i = 0, . . . , K − 1 :
10: d[i] ← d[i] + i
11: end for
12: return d
▶ ͜ͷΞϧΰϦζϜͷΞΠσΞͪ͜ΒΛࢀরͷ͜ͱ Link
tsutaj
ਖ਼͘͠࡞ΔϥϯμϜέʔε July 11, 2023 16 / 24