将sequence最后一个数字后面加上一个符号.pptVIP

将sequence最后一个数字后面加上一个符号.ppt

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
将sequence最后一个数字后面加上一个符号

HOMEWORK3 Problem 1: Grow the suffix tree for “b a a b c b b a b c”. Draw the intermediate tree with growing point and suffix links for each step of Ukkonen’s algorithm, as we did in the class. HOMEWORK3 HOMEWORK3 Problem 2: Show how to construct a minima tree for any sequence S of numbers in O(|S|) time. HOMEWORK3 Input:a sequence of numbers a1、a2、…an Output:a minima tree T Algorithm: 一、將sequence最後一個數字後面加上一個符號,令其為負無限大;令T為一個LIFO的stack,儲存minima tree; 二、將sequence第一個數字存到T中, 三、 for i:=2 to n+1 do input ai pop a minima tree from stack T compare ai with the root R of minima tree if R ai then let ai be the minima tree and push it into the stack T else HOMEWORK3 pop minima trees from stack T(T1,T2,….,Tk) until Tk ai or T is empty; combine these trees, let Tj-1 be the right child of Tj(j=2 to k-1), and the left child of ai be Tk-1,as T’ push T’ into stack T; end for loop; Prove : 此演算法為正確 PF:利用數學歸納法; (在第n 步的時候, 如果n+1 是’\0’ 則pop all minima trees from stack T and combining the trees as described in the algorithm, 可以得到minima tree.) 假設輸入n個數字時, 當n=2時,當我們輸入a2時,若a1a2,則a1會變成a2的左子樹,否則把兩個數字 存入stack中; Combining minima trees 可得到a1a2的minima tree. 假設當n=k時,是正確的; 當n=k+1時,若aipop出來minima tree的樹根,則ai與該樹根都會被push進去; 若aipop出來minima tree的樹根,則會建出一棵minima tree T’並push進入stack 中,因為根據演算法先pop出來的樹根會大於後來pop的樹根,而這些子樹會分別 成為後一個子樹的右子樹. Combining minima trees 可得到長度為k+1的minima tree. homework3 時間複雜度: 假設有n個數字輸入時,每個數字最多被比較兩次,即當我們輸入到數字ai時,與stack最上面的樹根R比較,若aiR則,ai會被push到stack中,之後當有數字aj當時stack pop出來的樹根R時,stack才會一直pop數字出來與aj比較,直到有個樹根比aj小,此時被pop出來的樹根會被combine起來,存到aj的左子樹,之後便不會在被拿出來比較了,故比較次數最多不超過2n次,所以時間複雜度為O(n) 。 TA’s comments: In another opinion, since each character must perform a multi-pop operation and be push into the stack either combining with existing minima trees or forming a new minima tree

文档评论(0)

ctuorn0371 + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档