Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 跳过列表的合并_Algorithm_Data Structures_Merge_Skip Lists - Fatal编程技术网

Algorithm 跳过列表的合并

Algorithm 跳过列表的合并,algorithm,data-structures,merge,skip-lists,Algorithm,Data Structures,Merge,Skip Lists,如何在O(n)时间复杂度(最坏情况)中将两个给定的跳过列表(每个都有n个键)合并为一个跳过列表 只是寻找算法-没有特定的实现/语言 store the two skip lists in two arrays: A,B merge the arrays. repeat until getting into root ('top' is a linked list containing only one element): for each second entry in the skip

如何在
O(n)
时间复杂度(最坏情况)中将两个给定的
跳过列表
(每个都有n个键)合并为一个
跳过列表

只是寻找算法-没有特定的实现/语言

store the two skip lists in two arrays: A,B
merge the arrays.
repeat until getting into root ('top' is a linked list containing only one element): 
   for each second entry in the skip list 'top' add a 'tag' (link 'upstairs' of the previous level)
实际上是O(n),因为存储和合并是O(n),在循环中,您需要迭代:

n+n/2+n/4+n/8+... = sigma(n/2^k) where k in (0,infinity) = 2n

我不确定我是否正确使用了跳过列表的术语(在循环中),但是我确定这个解决方案是正确的。如果你不明白什么,请告诉我。