欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > PPT文档下载  

    第03章跳跃表SkipLists.ppt

    • 资源ID:5273150       资源大小:147KB        全文页数:13页
    • 资源格式: PPT        下载积分:10金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要10金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    第03章跳跃表SkipLists.ppt

    6/21/2023 6:02 AM,Skip Lists,1,Skip Lists,S0,S1,S2,S3,奋俭卯兔夫坑亩睬颜成壮连仟忽酒屡雪聋罩农登盒搭钳硷喂陌摸烦黄禹半第03章跳跃表SkipLists第03章跳跃表SkipLists,6/21/2023 6:02 AM,Skip Lists,2,Outline and Reading,What is a skip list(3.5)OperationsSearch(3.5.1)Insertion(3.5.2)Deletion(3.5.2)ImplementationAnalysis(3.5.3)Space usageSearch and update timesComparison of dictionary implementations,消锻痒赡闻懂掷香酪奇皇殆鉴蜘舰榆哪亡椭拦韵邦件胳公侦斗抢叶鄂衷卞第03章跳跃表SkipLists第03章跳跃表SkipLists,6/21/2023 6:02 AM,Skip Lists,3,What is a Skip List,A skip list for a set S of distinct(key,element)items is a series of lists S0,S1,Sh such thatEach list Si contains the special keys+and-List S0 contains the keys of S in nondecreasing order Each list is a subsequence of the previous one,i.e.,S0 S1 ShList Sh contains only the two special keysWe show how to use a skip list to implement the dictionary ADT,+,31,-,64,+,31,34,-,23,S0,S1,S2,S3,囊韶囚诛辰殃篮瓤摊业厂潞锨毙酪悸录茧聚噶但舔理载蕊缝祟墒猜斜阉乐第03章跳跃表SkipLists第03章跳跃表SkipLists,6/21/2023 6:02 AM,Skip Lists,4,Search,We search for a key x in a a skip list as follows:We start at the first position of the top list At the current position p,we compare x with y key(after(p)x=y:we return element(after(p)x y:we“scan forward”x y:we“drop down”If we try to drop down past the bottom list,we return NO_SUCH_KEYExample:search for 78,S0,S1,S2,S3,+,31,-,64,+,31,34,-,23,56,64,78,+,31,34,44,-,12,23,26,芭欢往缅协坦赏欲霞摹精雕阅酬辉琐喧仿筐淘践迫蝶崖幸浑梁鹏荷悸唁梁第03章跳跃表SkipLists第03章跳跃表SkipLists,6/21/2023 6:02 AM,Skip Lists,5,Randomized Algorithms,A randomized algorithm performs coin tosses(i.e.,uses random bits)to control its executionIt contains statements of the typeb random()if b=0do A else b=1do B Its running time depends on the outcomes of the coin tosses,We analyze the expected running time of a randomized algorithm under the following assumptionsthe coins are unbiased,and the coin tosses are independentThe worst-case running time of a randomized algorithm is often large but has very low probability(e.g.,it occurs when all the coin tosses give“heads”)We use a randomized algorithm to insert items into a skip list,滋江诛蜘招滁举引乃宰叫受审汀肖尼谁吟瞄砷舀也袜呈妙逝骑赶砚猫锄忽第03章跳跃表SkipLists第03章跳跃表SkipLists,6/21/2023 6:02 AM,Skip Lists,6,To insert an item(x,o)into a skip list,we use a randomized algorithm:We repeatedly toss a coin until we get tails,and we denote with i the number of times the coin came up headsIf i h,we add to the skip list new lists Sh+1,Si+1,each containing only the two special keysWe search for x in the skip list and find the positions p0,p1,pi of the items with largest key less than x in each list S0,S1,SiFor j 0,i,we insert item(x,o)into list Sj after position pjExample:insert key 15,with i=2,Insertion,+,-,10,36,+,-,23,23,+,-,S0,S1,S2,S0,S1,S2,S3,p0,p1,p2,码骡灰曲躯巳配旺沛骤呼掠兰贷怕腾眉挚寞布绽赶乾揭搪蝎歪爸仅箕磊赖第03章跳跃表SkipLists第03章跳跃表SkipLists,6/21/2023 6:02 AM,Skip Lists,7,Deletion,To remove an item with key x from a skip list,we proceed as follows:We search for x in the skip list and find the positions p0,p1,pi of the items with key x,where position pj is in list SjWe remove positions p0,p1,pi from the lists S0,S1,SiWe remove all but one list containing only the two special keysExample:remove key 34,-,+,45,12,-,+,23,23,-,+,S0,S1,S2,-,+,S0,S1,S2,S3,-,+,45,12,23,34,-,+,34,-,+,23,34,p0,p1,p2,骇怨纹僚梳续庶栈兆罕咆翼慌字舀依政挂俯谓陨力莹勇帧憋蕉肃斧琢鲤淖第03章跳跃表SkipLists第03章跳跃表SkipLists,6/21/2023 6:02 AM,Skip Lists,8,Implementation,We can implement a skip list with quad-nodesA quad-node stores:itemlink to the node beforelink to the node afterlink to the node belowlink to the node afterAlso,we define special keys PLUS_INF and MINUS_INF,and we modify the key comparator to handle them,x,quad-node,型班腿瞅宣含奠粘幂神堡邹颊缉辞驭则呵车仍毡迸终牌蛾诣高砰媒静除纹第03章跳跃表SkipLists第03章跳跃表SkipLists,6/21/2023 6:02 AM,Skip Lists,9,Space Usage,The space used by a skip list depends on the random bits used by each invocation of the insertion algorithmWe use the following two basic probabilistic facts:Fact 1:The probability of getting i consecutive heads when flipping a coin is 1/2iFact 2:If each of n items is present in a set with probability p,the expected size of the set is np,Consider a skip list with n itemsBy Fact 1,we insert an item in list Si with probability 1/2iBy Fact 2,the expected size of list Si is n/2i The expected number of nodes used by the skip list is,Thus,the expected space usage of a skip list with n items is O(n),渤负乓春报镇字丸摈钥女讯轿贞疑六凛借焦逸守彤袜象勤侗踩吟君乍壤蕾第03章跳跃表SkipLists第03章跳跃表SkipLists,6/21/2023 6:02 AM,Skip Lists,10,Height,The running time of the search an insertion algorithms is affected by the height h of the skip listWe show that with high probability,a skip list with n items has height O(log n)We use the following additional probabilistic fact:Fact 3:If each of n events has probability p,the probability that at least one event occurs is at most np,Consider a skip list with n itemsBy Fact 1,we insert an item in list Si with probability 1/2iBy Fact 3,the probability that list Si has at least one item is at most n/2iBy picking i=3log n,we have that the probability that S3log n has at least one item isat most n/23log n=n/n3=1/n2Thus a skip list with n items has height at most 3log n with probability at least 1-1/n2,绳谅蝴黎不戍棱棉胎阜汉印锨缆疥崩冬溺谷融放搓析霓没菊挡矫词乞僻粱第03章跳跃表SkipLists第03章跳跃表SkipLists,6/21/2023 6:02 AM,Skip Lists,11,Search and Update Times,The search time in a skip list is proportional tothe number of drop-down steps,plusthe number of scan-forward stepsThe drop-down steps are bounded by the height of the skip list and thus are O(log n)with high probabilityTo analyze the scan-forward steps,we use yet another probabilistic fact:Fact 4:The expected number of coin tosses required in order to get tails is 2,When we scan forward in a list,the destination key does not belong to a higher listA scan-forward step is associated with a former coin toss that gave tailsBy Fact 4,in each list the expected number of scan-forward steps is 2Thus,the expected number of scan-forward steps is O(log n)We conclude that a search in a skip list takes O(log n)expected timeThe analysis of insertion and deletion gives similar results,箍渭风阑霖搀订贵早谣牢庚袭呻焰铂诸剖荡骆舀丛邓福糕猪概溢搓膜篡菱第03章跳跃表SkipLists第03章跳跃表SkipLists,6/21/2023 6:02 AM,Skip Lists,12,Implementing a Dictionary,Comparison of efficient dictionary implementations,名所蛇夕挡费甜救莉烈江妨逆繁溺兆横欠咽泄郡撅雌瓢柞假痔拿瘟瘤泌排第03章跳跃表SkipLists第03章跳跃表SkipLists,6/21/2023 6:02 AM,Skip Lists,13,Summary,A skip list is a data structure for dictionaries that uses a randomized insertion algorithmIn a skip list with n items The expected space used is O(n)The expected search,insertion and deletion time is O(log n),Using a more complex probabilistic analysis,one can show that these performance bounds also hold with high probabilitySkip lists are fast and simple to implement in practice,砒钥烹外滑防具依遮钱细灾朱铰躺啥扇俺朋们止浓酚克员诚奔曰奥炬屡嘴第03章跳跃表SkipLists第03章跳跃表SkipLists,

    注意事项

    本文(第03章跳跃表SkipLists.ppt)为本站会员(sccc)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开