コンテンツにスキップ

「スキップリスト」の版間の差分

出典: フリー百科事典『ウィキペディア(Wikipedia)』
削除された内容 追加された内容
Nskn (会話 | 投稿記録)
skip listの翻訳です
 
m編集の要約なし
1行目: 1行目:

スキップリスト([[:en:Skip list|skip list]])は確率的アルゴリズムのためのデータ構造であり、並列な[[連結リスト]]に基づいている。効率は2分探索木と同等である(大半の操作について平均O(log ''n'')である。

'''スキップリスト'''('''skip list''')は確率的アルゴリズムのためのデータ構造であり、並列な[[連結リスト]]に基づいている。効率は2分探索木と同等である(大半の操作について平均O(log ''n'')である。



基本的にスキップリストは順序つきの[[連結リスト]]の前向きのリンクを追加したものである。Pughによる原著論文によると、前向きのリンクは''Geometric/Negative Binomial distribution''という乱数を用いた手法で追加されていて、リスト上の探索においてリストの一部を高速に飛ばすことができる。挿入と探索と削除は対数の乱数時間で行われる。

基本的にスキップリストは順序つきの[[連結リスト]]の前向きのリンクを追加したものである。Pughによる原著論文によると、前向きのリンクは''Geometric/Negative Binomial distribution''という乱数を用いた手法で追加されていて、リスト上の探索においてリストの一部を高速に飛ばすことができる。挿入と探索と削除は対数の乱数時間で行われる。

14行目: 14行目:

1-2-3-4-5-6-7-8-9-10

1-2-3-4-5-6-7-8-9-10



目的の要素を探すために、最上層のリストの先頭の要素から始めて、目的の要素と同じかそれ以下の要素のうち最後のものまでスキャンする。各連結リストのリンクを辿る数の期待値は1/''p''となる。これは目的の要素から後ろに戻って上層のリストにつながる要素に到達するまでの期待値であることから理解できる。従って探索の総コストはO(log<sub>1/''p''</sub> n / p)で、''p''を固定すればO(log ''n'')である。''p''にさまざまな値を選ぶことで、探索時間とメモリ使用量のトレードオフをとることが可能である。

目的の要素を探すために、最上層のリストの先頭の要素から始めて、目的の要素と同じかそれ以下の要素のうち最後のものまでスキャンする。各連結リストのリンクを辿る数の期待値は1/''p''となる。これは目的の要素から後ろに戻って上層のリストにつながる要素に到達するまでの期待値であることから理解できる。従って探索の総コストはO(log<sub>1/''p''</sub> n / p)で、''p''を固定すればO(log ''n'')である。''p''にさまざまな値を選ぶことで、探索時間とメモリ使用量の[[トレードオフ]]をとることが可能である。



挿入と削除[[連結リスト]]の対応する操作と同様の実装になるが、高い要素は2つ以上の連結リストに対して挿入及び削除する必要がある。

挿入と削除[[連結リスト]]の対応する操作と同様の実装になるが、高い要素は2つ以上の連結リストに対して挿入及び削除する必要がある。


2006年11月9日 (木) 20:32時点における版


(skip list)2(O(log n)

PughGeometric/Negative Binomial distribution

1990William Pugh


ii+1p1/(1-p)()O(log1/p n)
1
1-----4---6
1---3-4---6-----9
1-2-3-4-5-6-7-8-9-10

辿1/pO(log1/p n / p)pO(log n)p使

2

(PrintEntireListToScreen())O(n)(ii=m*2^n(m)n1)

1i2222

Let us prove these two claims. First, to prove that the search time is guaranteed to be logarithmic. Suppose we search for and find node n where n is the position of the found node among the nodes of level 1 or higher. If n is even, then there is a 50/50 chance that it is higher than level 1. This time, though, if it is not higher than level 1 then node n-1 is guaranteed to be higher than level 1. If n is odd, then there is a 50/50 chance that it is higher than level 1. Given that it is not, there is a 50/50 chance that node n-1 is higher than level 1. Given that this is not either, we are guaranteed that node n-2 is higher than level 1. We repeat the analysis for nodes of level 2 or higher, level 3 or higher, etc. always keeping in mind that n is the position of the node among the ones of level k or higher for integer k. So the search time if constant in the best case (if the found node is the highest possible level) and 2 times the worst case for the search time for the totally derandomized skip-list (because we have to keep moving left twice rather than keep moving left once).

Next, let's prove something about the probability of an adversarial user's guess of a node being level k or higher being correct. First, the adversarial user has a 50/50 chance of correctly guessing that a particular node is level 2 or higher. If he/she knows the positions of two consecutive nodes of level 2 or higher, and knows that the one on the left is in an odd numbered position among the nodes of level 2 or higher, he/she has a 50/50 chance of correctly guessing which one is of level 3 or higher. So, his/her probibility of being correct, when guessing that a node is level 3 or higher, is 1/4. Inductively continuing this analysis, we see that his/her probability of guessing that a particular node is level k or higher is 1/(2^(k-1)).

2

B([1])


Willam Pugh辿



Skip lists are a probabilistic data structure that seem likely to supplant balanced trees as the implementation method of choice for many applications. Skip list algorithms have the same asymptotic expected time bounds as balanced trees and are simpler, faster and use less space.

使[2]

参照

  • Pugh, William (June 1990). “Skip lists: a probabilistic alternative to balanced trees”. Communications of the ACM 33: 668-676. 

外部リンク