查找多个跳过列表的交叉点
这是用于查找两个跳过列表的交点的算法:
我们可以看到,与一次移动一步相比,“跳过跳跃”在效率方面受益匪浅。
但是在这里我很好奇,如果将这种情况扩展到多个跳过列表,说100个列表怎么办?目前,我只考虑分裂和征服,其中多个跳过列表按2分组,并顺序得出其相交,然后合并解决方案,这听起来很耗时且效率低下。
确定多个跳过列表的相交以及花费最少的时间的更好方法是什么?
This is the algorithm for finding the intersection of two skip lists:
(Finding Intersection of two skip lists - copyright to Stanford)
We can see that the "jumping by skips" benefits a lot in terms of efficiency compared to moving one step at a time.
But here I'm curious, what if the case is extended to multiple skip lists, say 100 lists? Currently, I only think of divide and conquer, in which the multiple skip lists are grouped by 2, and sequentially derive its intersection and later merge the solution, which sounds time-consuming and inefficient.
What is the better way to determine the intersections of multiple skip lists with the least time spent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
初始化一个指针,直达每个跳过列表的开头。
我们将维护两件事:
在每个步骤:
当任何列表耗尽时停止(您需要推进指针,但不能推进。)
这是经典编程面试问题“合并K分类列表”的略有变化 - 这里的算法非常相似。我建议看看这个答案中的任何东西尚不清楚。
Initialize a pointer to the beginning of each of your skip lists.
We will maintain two things:
At each step:
Stop when any list runs out (you need to advance a pointer but can't.)
This is a slight twist on a classic programming interview problem "Merge k sorted lists" -- the algorithm here is very similar. I'd suggest looking at that if anything in this answer is unclear.