Simple Linear Work Suffix Array Construction J. Kärkkäinen, P. Sanders Proc. 30th International Conference on Automata, Languages and Programming 2003.

Slides:



Advertisements
Similar presentations
Introduction to Java Programming Lecture 10 Method Benefits, Declaring, and Calling Methods.
Advertisements

Algorithms Chapter 15 Dynamic Programming - Rod
2010/12/12
: Arrange the Numbers ★★★☆☆ 題組: Contest Archive with Online Judge 題號: 11481: Arrange the Numbers 解題者:李重儀 解題日期: 2008 年 9 月 13 日 題意: 將數列 {1,2,3, …,N}
: A-Sequence 星級 : ★★☆☆☆ 題組: Online-judge.uva.es PROBLEM SET Volume CIX 題號: Problem D : A-Sequence 解題者:薛祖淵 解題日期: 2006 年 2 月 21 日 題意:一開始先輸入一個.
:Word Morphing ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10508:word morphing 解題者:楊家豪 解題日期: 2006 年 5 月 21 日 題意: 第一行給你兩個正整數, 第一個代表下面會出現幾個字串,
1 Q10276: Hanoi Tower Troubles Again! 星級 : ★★★ 題組: Online-judge.uva.es PROBLEM SET Volume CII 題號: Q10276: Hanoi Tower Troubles Again! 解題者:薛祖淵 解題日期: 2006.
Mar. 14, :Vito ’ s family ★☆☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10014:Vito’s family 解題者:劉淑惠、侯沛彣 解題日期: 2006 年 3 月 9 日 題意: Vito.
1 第一章 Word 的基本觀念 內容概要: Word 的特色 啟動與離開 Word 的方法 滑鼠游標與外型的介紹 基本操作 Word 視窗法則 使用 Word 遭遇問題時, 應如何利用軟體特 性而獲得輔助解說.
1.1 線性方程式系統簡介 1.2 高斯消去法與高斯-喬登消去法 1.3 線性方程式系統的應用(-Skip-)
亂數產生器安全性評估 之統計測試 SEC HW7 姓名:翁玉芬 學號:
Lecture 8 Median and Order Statistics. Median and Order Statistics2 Order Statistics 問題敘述 在 n 個元素中,找出其中第 i 小的元素。 i = 1 ,即為找最小值。 i = n ,即為找最大值。 i = 或 ,即為找中位數。
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 肆 資料分析與表達.
Analyzing Algorithms Based on: 1. 物件導向資料結構 — 使用 Java 語言, 江振 瑞 著, 松崗圖書公司, Introduction to the Design and Analysis of Algorithms -- A strategic.
Monte Carlo Simulation Part.2 Metropolis Algorithm Dept. Phys. Tunghai Univ. Numerical Methods C. T. Shih.
第一章 演算法:效率、分析與量級 1.1演算法 1.2發展有效率演算法的重要性 1.3演算法的分析 1.4量級(Order)
第 6 章 關連分析: 基本概念和演算法      © 2008 台灣培生教育出版 (Pearson Education Taiwan)
信度.
Chapter 13 塑模靜態觀點:物件圖 Static View : Object Diagram.
Greedy Algorithms. 2 Greedy Methods ( 描述 1) * 解最佳化問題的演算法, 其解題過程可看成是由一 連串的決策步驟所組成, 而每一步驟都有一組選擇 要選定. * 一個 greedy method 在每一決策步驟總是選定那目 前看來最好 的選擇. *Greedy.
Introduction to Java Programming Lecture 17 Abstract Classes & Interfaces.
: The largest Clique ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11324: The largest Clique 解題者:李重儀 解題日期: 2008 年 11 月 24 日 題意: 簡單來說,給你一個 directed.
3-3 使用幾何繪圖工具 Flash 的幾何繪圖工具包括線段工具 (Line Tool) 、橢圓形工具 (Oval Tool) 、多邊星形 工具 (Rectangle Tool) 3 種。這些工具畫出 來的幾何圖形包括了筆畫線條和填色區域, 將它們適當地組合加上有技巧地變形與配 色, 不但比鉛筆工具簡單,
Introduction to Java Programming Lecture 10 Array I Declaring, Creating, and Initializing Arrays.
: Happy Number ★ ? 題組: Problem Set Archive with Online Judge 題號: 10591: Happy Number 解題者:陳瀅文 解題日期: 2006 年 6 月 6 日 題意:判斷一個正整數 N 是否為 Happy Number.
: Fast and Easy Data Compressor ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10043: Fast and Easy Data Compressor 解題者:葉貫中 解題日期: 2007 年 3.
Digital Signal Processing with Examples in M ATLAB ® Chap 1 Introduction Ming-Hong Shih, Aug 25, 2003.
Motion Doodles: An Interface for Sketching Character Motion SIGGRAPH ’04 Speaker: Alvin Date: 5 July 2004.
選舉制度、政府結構與政 黨體系 Cox (1997) Electoral institutions, cleavage strucuters, and the number of parties.
第三章 自動再裝載運用篇 使用時機:裝載計劃完成時,尚有剩餘空 間的情形,維持已固定計劃而繼續做裝載 最佳化。以支持次日裝載計劃而提前調整 作業模式。 裝載物品設定和裝載容器設定如前兩章介 紹,於此不再重複此動作,直接從裝載計 劃設定開始,直接從系統內定的物品和容 器選取所需.
: Problem A : MiniMice ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11411: Problem A : MiniMice 解題者:李重儀 解題日期: 2008 年 9 月 3 日 題意:簡單的說,題目中每一隻老鼠有一個編號.
: Count DePrimes ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11408: Count DePrimes 解題者:李育賢 解題日期: 2008 年 9 月 2 日 題意: 題目會給你二個數字 a,b( 2 ≦ a ≦ 5,000,000,a.
Single-Source Shortest Paths
:Nuts for nuts..Nuts for nuts.. ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 10944:Nuts for nuts.. 解題者:楊家豪 解題日期: 2006 年 2 月 題意: 給定兩個正整數 x,y.
The application of boundary element evaluation on a silencer in the presence of a linear temperature gradient Boundary Element Method 期末報告 指導老師:陳正宗終身特聘教授.
資料結構實習-一 參數傳遞.
Lecture 7 Sorting in Linear Time. Sorting in Linear Time2 7.1 Lower bounds for sorting 本節探討排序所耗用的時間複雜度下限。 任何一個以比較為基礎排序的演算法,排序 n 個元 素時至少耗用 Ω(nlogn) 次比較。
Dynamic Multi-signatures for Secure Autonomous Agents Panayiotis Kotzanikolaou Mike Burmester.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2008.
: Problem G e-Coins ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10306: Problem G e-Coins 解題者:陳瀅文 解題日期: 2006 年 5 月 2 日 題意:給定一個正整數 S (0
: Beautiful Numbers ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11472: Beautiful Numbers 解題者:邱經達 解題日期: 2011 年 5 月 5 日 題意: 若一個 N 進位的數用到該.
: 05-2 Rendezvous ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11015: 05-2 Rendezvous 解題者:池明洋 解題日期: 2006 年 4 月 16 日 題意: 給 node N 個 , edge.
Teacher : Ing-Jer Huang TA : Chien-Hung Chen 2015/6/25 Course Embedded Systems : Principles and Implementations Weekly Preview Question CH 2.4~CH 2.6 &
函式 Function Part.2 東海大學物理系‧資訊教育 施奇廷. 遞迴( Recursion ) 函式可以「呼叫自己」,這種動作稱為 「遞迴」 此程式的執行結果相當於陷入無窮迴圈, 無法停止(只能按 Ctrl-C ) 這給我們一個暗示:函式的遞迴呼叫可以 達到部分迴圈的效果.
: GCD - Extreme II ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11426: GCD - Extreme II 解題者:蔡宗翰 解題日期: 2008 年 9 月 19 日 題意: 最多 20,000 組測資,題目會給一個數字.
JAVA 程式設計與資料結構 第二十章 Searching. Sequential Searching Sequential Searching 是最簡單的一種搜尋法,此演 算法可應用在 Array 或是 Linked List 此等資料結構。 Sequential Searching 的 worst-case.
演算法 8-1 最大數及最小數找法 8-2 排序 8-3 二元搜尋法.
: Ubiquitous Religions ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10583: Ubiquitous Religions 解題者:吳佳樺 解題日期: 2010 年 3 月 18 日 題意: 一開始給予兩個數字.
逆向選擇和市場失調. 定義  資料不對稱 在交易其中,其中一方較對方有多些資料。  逆向選擇 出現在這個情況下,就是當買賣雙方隨意在 市場上交易,與比較主動交易者作交易為佳 。
845: Gas Station Numbers ★★★ 題組: Problem Set Archive with Online Judge 題號: 845: Gas Station Numbers. 解題者:張維珊 解題日期: 2006 年 2 月 題意: 將輸入的數字,經過重新排列組合或旋轉數字,得到比原先的數字大,
Chapter 10 m-way 搜尋樹與B-Tree
: Function Overloading ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11032:Function Overloading 解題者:許智祺 解題日期: 2007 年 5 月 8 日 題意:判對輸入之數字是否為.
ProblemH - Hyper Toy Soldiers 星級 : ??? 題組: Online-judge.uva.es PROBLEM SET Volume CIV 題號: Problem H - Hyper Toy Soldiers 解題者: 柯名澤 解題日期: 2006 年.
JAVA 程式設計與資料結構 第十六章 Hash Tables. Introduction Hash Tables 結構為一個 Array ,稱之為 Bucket array 。 如果想要新增一個物件,要根據這個物件的特性 將其加入 Hash Table 內。 Bucket Array 用 A 來代替,其.
幼兒行為觀察與記錄 第五章 觀察記錄法的簡介.
Extreme Discrete Summation ★★★★☆ 題組: Contest Archive with Online Judge 題號: Extreme Discrete Summation 解題者:蔡宗翰 解題日期: 2008 年 10 月 13 日.
Probability Distribution 機率分配 汪群超 12/12. 目的:產生具均等分配的數值 (Data) ,並以 『直方圖』的功能計算出數值在不同範圍內出現 的頻率,及繪製數值的分配圖,以反應出該 機率分配的特性。
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2009.
2005/7 Linear system-1 The Linear Equation System and Eliminations.
冷凍空調自動控制 - 系統性能分析 李達生. Focusing here … 概論 自動控制理論發展 自控系統設計實例 Laplace Transform 冷凍空調自動控制 控制系統範例 控制元件作動原理 控制系統除錯 自動控制理論 系統穩定度分析 系統性能分析 PID Controller 自動控制實務.
兩黨與多黨政黨體系 Lijphart (1984) Party Systems: Two-Party and Multiparty Patterns.
:Commandos ★★★☆☆ 題組: Contest Archive with Online Judge 題號: 11463: Commandos 解題者:李重儀 解題日期: 2008 年 8 月 11 日 題意: 題目會給你一個敵營區內總共的建築物數,以及建築物 之間可以互通的路有哪些,並給你起點的建築物和終點.
: SAM I AM ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11419: SAM I AM 解題者:李重儀 解題日期: 2008 年 9 月 11 日 題意: 簡單的說,就是一個長方形的廟裡面有敵人,然 後可以橫的方向開砲或縱向開砲,每次開砲可以.
:Problem E.Stone Game ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10165: Problem E.Stone Game 解題者:李濟宇 解題日期: 2006 年 3 月 26 日 題意: Jack 與 Jim.
幼兒行為觀察與記錄 第八章 事件取樣法.
: How many 0's? ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11038: How many 0’s? 解題者:楊鵬宇 解題日期: 2007 年 5 月 15 日 題意:寫下題目給的 m 與 n(m
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 肆 資料分析與表達.
1 Query Optimization for Inter Document Relationships in XML Structured Document Radha Senthilkumar, A. Kannan, D.Vimala, M. Bhuvaneswari Department of.
Parallel Suffix Array Construction by Accelerated Sampling Matthew Felice Pace University of Warwick Joint work with Alexander Tiskin University of Warwick.
Presentation transcript:

Simple Linear Work Suffix Array Construction J. Kärkkäinen, P. Sanders Proc. 30th International Conference on Automata, Languages and Programming 2003

Work 在分析 parallel algorithm 時,常用到二種 複雜度 : time and work complexity. 1)Time t(n) : 須執行多少步驟. 2)Work w(n): t(n) * ( 所用到的 processors 的數目 ). 這篇 paper 主要的貢獻在於它的方法應用在 External Memory 或 Cache Oblivious model 上也是 optimal, 而應用在 BSP 和 EREW-PRAM model 上則可以和現有 的演算法有相同的 work complexity, 但更好的 time complexity. 但以下報告內容將只針對 RAM model 的 time complexity 作分析.

Today’s Work Suffix ArrayDepth Array Suffix Tree

Model of Alphabet Constant alphabet: The size of alphabet is constant. Integer alphabet: Characters are integers in [1 … n], where n is the number of input characters.

A suffix array SA of s is the result of sorting the suffixes of s lexicographically. ex: s = [ a b a ] s 0 = a b a s 1 = b a s 2 = a Topic 1: Suffix Array => SA = [ s 2 s 0 s 1 ] 012 [ ] in implementation= We call the suffix starting from the the index i as the ith suffix. Some conventions: 除 3 不等於 0 的 suffix = { ith suffix| i != 0 mod 3} 除 3 等於 0 的 suffix = { ith suffix| i == 0 mod 3}

Suffix Array Problem Input: a string s with length n Output: a suffix array SA of s Time: O(n)

GetSA Algorithm Outline Step 1: SA ≠ 0 = sort the suffixes starting at position i ≠ 0 mod 3. Step 2: SA = 0 = sort the suffixes starting at position i = 0 mod 3. Step 3: SA = merge SA = 0 and SA ≠ 0.

選代表 s = m i s s i s s i p p i Radix sort Step1: SA ≠ 0 = sort the suffixes starting at position i ≠ 0 mod Let 代 = [ ] => getSA( 代 ) = SA 代 = [ ] in T(2n/3) Claim: SA ≠0 = SA 代 $ m i s s i s s i p p i

Why SA 代 = SA ≠0 ? 代 = [ ] s = m i s s i s s i p p i 代 1 = 代4代4 代7代7 代 10 代2代2 代5代5 代8代8 = = = = = 5 4 = 4 s1s1 s4s4 s7s7 s 10 s2s2 s5s5 s8s8 = i s s i s s i p p i = i s s i p p i = i p p i = i = s s i s s i p p i s s i p p i = p p i = SA 代 = SA ≠ 0 = [ ], It suffices to show that 代 i s i < s j.

Case 1: i = j mod 代 = [ ] s = m i s s i s s i p p i $ $ Ex: 代 4 = [ ] s 4 = [ i s s i p p i $ $ ] 代 1 = [ ] s 1 = [ i s s i s s i p p i $ $ ] 代 i s i < s j 代 4 < 代 1 s 4 < s 1

Case 2: i ≠ j mod s 12 = [ ] s = m i s s i s s i p p i $ $ Ex: 代 4 = [ ] s 4 = [ i s s i p p i $ $ ] 代 5 = [ 6 5 ] s 5 =[ s s i p p i ] 代 i s i < s j 代 4 < 代 5 s 4 < s 5

Step2: SA = 0 = sort the suffixes starting at position i = 0 mod 3. ∵ The rank of s j among {s k | k ≠ 0 mod 3 } was determined in Step1 for all j ≠ 0 mod 3. ∴ Let rank ≠0 (s j ) = rank of s j among {s k | k ≠ 0 mod 3 } for all j ≠ 0 mod 3. SA =0 = radix sort { (s[i], rank ≠0 (s i+1 ) ) | i = 0 mod 3 }.

Step 3: SA = merge SA = 0 and SA ≠ 0. SA = 0 = [s 0 s 9 s 6 s 3 ] SA ≠0 = [s 11 s 10 s 7 s 1 s 8 s 5 s 2 ] SA = merge SA = 0 and SA ≠0 =[s 11 s 10 s 7 s 4 s 1 s 0 s 9 s 8 s 6 s 3 s 5 s 2 ] It is in time O(n) if we can determine the relative order of S i  SA = 0 and S j  SA ≠0 in constant time.

Compare S i and S j where i = 0, j ≠ 0 mod 3: case 1: j = 1 mod 3 ∵ i + 1 = 1 mod 3, j+1 = 2 mod 3 ∴ compare (s[i], rank ≠0 (s i+1 ) ) with (s[j], rank ≠0 (s j+1 ) ) in constant time. case 2: j = 2 mod 3 ∵ i + 2 = 2 mod 3, j+2 = 1 mod 3 ∴ compare (s[i], s[i+1], rank ≠0 (s i+2 )) with (s[j], s[j+1], rank ≠0 (s j+2 )) in constant time

Time complexity analysis Step1: O(n) + T(2n/3) Step2: O(n) Step3: O(n) T(n) = O(n) + T(2n/3) = O(n)

Topic 2: Depth array Definition of Depth array: sksk sjsj DA[i] = longest common prefix of S j and S k i-1 i SjSj SA = SkSk DA = 0 1 n n i

Depth array problem Input: a string s and its suffix array SA. Output: a depth array DA of s. Time: O(|s|) = O(n)

s i ’ sisi DA[ rank( i ) ] = d i rank( i ) SiSi SA = S i ’ DA = 0 1 n n rank( i ) didi... S =... 0n - 1 ii’ SiSi S i ’... Lemma1: d i ≥ d i-1 -1

rank( i ) SiSi SA = S i ’ DA = rank( i ) rank( i - 1) S i - 1 S (i – 1)’ didi d i-1 rank( i - 1) sisi 1 s i- 1 didi d i s i ’ s ( i- 1) ’ d i-1 S = i 0 n - 1 i-1... S i-1 SiSi... Lemma1: d i ≥ d i-1 -1

sisi 1 s i- 1 Pf: Lemma1: d i ≥ d i-1 -1 didi d i s i ’ s ( i- 1) ’

sisi 1 s i- 1 < -><-=> if Pf: Lemma1: d i ≥ d i-1 -1 didi d i s i ’ s ( i- 1) ’ s (i-1)’+1 s i ’ < s (i- 1)’+1 < s i

By Lemma1: d i ≥ d i-1 – 1, it suffices to compare s i and s i ’ from the d i-1 -th character. How to compute d i when d i-1 is given ? didi s i ’ sisi d i-1 - 1

Algorithm GetDepth Input: A string s and its suffix array SA 1. d 1 = by naïvely comparing s 1 and s 1’ ; 2. For i := 2 to n-1 do 3. d i = by comparing s i and s i ’ from the (d i-1 )-th character; 4. End for Time complexity Analysis : Iteration i: ( d i – d i-1 + 1) + 1 = d i – d i Total =

Topic 3: Suffix Tree Problem Input: a string s with length n. Output: a suffix tree ST of s. Time: O(|s|) = O(n)

Algorithm GetST(s) 1. SA = suffix array of s; 2. DA = depth array of s; 3. For i:=0 to n-1 ST i = add the SA[i]-th suffix into ST i End for 5. Return ST n-1 ; GetST Algorithm Outline

How to add the SA[i]-th suffix into ST i-1 ? Observation: The SA[i-1]-th suffix is the right_most_path RP of ST i-1, so the longest common prefix of RP and SA[i]-th suffix is DA[ i ]. DA[ i ] [ (SA[i] + DA[i]), - ] i-1 i SjSj SA = SkSk DA = 0 1 n i

Each node is go over at most once DA[ i ] [ (SA[i] + DA[i]), - ] Nodes on this path will not be go over again.

Time Complexity Analysis Because each node is go over at most once and there are at most 2n nodes in the tree, the time complexity is O(n).

Conclusions Advantages :  Alphabet 的限制  硬碟的 I/O  Easy to show Disadvantages :  沒有 incremental 的特性