Module 9: String Matching

Size: px
Start display at page:

Download "Module 9: String Matching"

Transcription

1 Module 9: Strig Mtchig CS 240 Dt Structures d Dt Mgemet T. Biedl K. Lctot M. Sepehri S. Wild Bsed o lecture otes y my previous cs240 istructors Dvid R. Cherito School of Computer Sciece, Uiversity of Wterloo Witer 2018 Refereces: Goodrich & Tmssi 9.1 versio :16 Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

2 Outlie 1 Strig Mtchig Itroductio Strig Mtchig with Fiite Automt Kuth-Morris-Prtt lgorithm Boyer-Moore Algorithm Ri-Krp Algorithm Suffix Trees Coclusio Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer 2018

3 Outlie 1 Strig Mtchig Itroductio Strig Mtchig with Fiite Automt Kuth-Morris-Prtt lgorithm Boyer-Moore Algorithm Ri-Krp Algorithm Suffix Trees Coclusio Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer 2018

4 Ptter Mtchig Defiitio [1] Serch for strig (ptter) i lrge ody of text T [0.. 1] The text (or hystck) eig serched withi P[0..m 1] The ptter (or eedle) eig serched for Strigs over lphet Σ Retur the first i such tht P[j] = T [i + j] for 0 j m 1 This is the first occurrece of P i T If P does ot occur i T, retur FAIL Applictios: Iformtio Retrievl (text editors, serch egies) Bioiformtics Dt Miig Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

5 Ptter Mtchig Defiitio [2] Exmple: T = Where is he? P 1 = he P 2 = who Defiitios: Sustrig T [i..j] 0 i j < : strig of legth j i + 1 which cosists of chrcters T [i],... T [j] i order A prefix of T : sustrig T [0..i] of T for some 0 i < A suffix of T : sustrig T [i.. 1] of T for some 0 i 1 Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

6 Geerl Ide of Algorithms Ptter mtchig lgorithms cosist of guesses d checks: A guess is positio i such tht P might strt t T [i]. Vlid guesses (iitilly) re 0 i m. A check of guess is sigle positio j with 0 j < m where we compre T [i + j] to P[j]. We must perform m checks of sigle correct guess, ut my mke (my) fewer checks of icorrect guess. We will digrm sigle ru of y ptter mtchig lgorithm y mtrix of checks, where ech row represets sigle guess. Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

7 Brute-force Algorithm Ide: Check every possile guess. BruteforcePM(T [0.. 1], P[0..m 1]) T : Strig of legth (text), P: Strig of legth m (ptter) 1. for i 0 to m do 2. for j 0 to m 1 do 3. if T [i + j]!= P[j] the 4. rek 5. if j = m the 6. retur i 7. retur FAIL Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

8 Brute-Force Exmple Exmple: T =, P = Wht is the worst possile iput? P = m 1, T = Worst cse performce Θ(( m + 1)m) m /2 Θ(m) Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

9 How to improve? More sophisticted lgorithms Do extr preprocessig o the ptter P Determiistic fiite utomt (DFA), KMP Boyer-Moore Ri-Krp We elimite guesses sed o completed mtches d mismtches. Do extr preprocessig o the text T Suffix-trees We crete dt structure to fid mtches esily. Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

10 Outlie 1 Strig Mtchig Itroductio Strig Mtchig with Fiite Automt Kuth-Morris-Prtt lgorithm Boyer-Moore Algorithm Ri-Krp Algorithm Suffix Trees Coclusio Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer 2018

11 Strig Mtchig with Fiite Automt Exmple: Automto for the ptter P = c Σ Σ c You should e fmilir with: fiite utomto, DFA, NFA, covertig NFA to DFA trsitio fuctio δ, sttes Q, cceptig sttes F Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

12 Strig Mtchig with Fiite Automt Exmple: Automto for the ptter P = c Σ Σ c You should e fmilir with: fiite utomto, DFA, NFA, covertig NFA to DFA trsitio fuctio δ, sttes Q, cceptig sttes F The ove fiite utomtio is NFA Stte q expresses we hve see P[0..q 1] NFA ccepts T if d oly if T cotis c But evlutig NFAs is very slow. Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

13 Strig mtchig with DFA C show: There exists equivlet smll DFA.,c Σ c c,c c,c,c Esy to test whether P is i T. But how do we fid the rcs? Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

14 Strig mtchig with DFA Code There is o eed to uild explicit DFA with odes d rcs. All tht is eeded is the trsitio-fuctio δ(q, c) = stte to go to c q δ(q, c) C the test for ptter i O() time y prsig text with DFA. DFA-PM(T [0.. 1], P[0..m 1]) T : Strig of legth (text), P: Strig of legth m (ptter) 1. δ trsitio fuctio for DFA 2. q 0 // curret stte 3. for i 0 to 1 do 4. q δ(q, T [i]) 5. if q = m 6. retur Ptter occurs with shift i (m 1) 7. retur FAIL Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

15 Strig mtchig with DFA Exmple Exmple: T = c, P = c,c Σ c c,c c,c,c T : c P: c to stte 4 () () () () c to stte 4 () () () () c q: (fter redig this chrcter) Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

16 Strig mtchig with DFA Trsitios Let P the ptter to serch, of legth m. The stte of the utomto is i {0,..., m} Stte q represets the text tht hs ee prsed so fr eds with P[0..q 1], (d there is o loger prefix of P tht it eds with) Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

17 Strig mtchig with DFA Trsitios Let P the ptter to serch, of legth m. The stte of the utomto is i {0,..., m} Stte q represets the text tht hs ee prsed so fr eds with P[0..q 1], (d there is o loger prefix of P tht it eds with) If the ext chrcter is c d does ot exted ptter: The text tht hs ee prsed so fr eds with P[0...q 1] c This is ot prefix of P Wt: The logest prefix of P tht is suffix of P[0..q 1] c The ew stte is the legth of tht prefix Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

18 Strig mtchig with DFA Trsitios Let P the ptter to serch, of legth m. The stte of the utomto is i {0,..., m} Stte q represets the text tht hs ee prsed so fr eds with P[0..q 1], (d there is o loger prefix of P tht it eds with) If the ext chrcter is c d does ot exted ptter: The text tht hs ee prsed so fr eds with P[0...q 1] c This is ot prefix of P Wt: The logest prefix of P tht is suffix of P[0..q 1] c The ew stte is the legth of tht prefix Exmple: q c P[0..q 1] c Prefixes of P logest δ(q, c) 5 Λ,,,,,, Λ,,,,,,... 1 Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

19 Strig mtchig with DFA Rutime Mtchig time o text strig of legth is Θ() Preprocessig c clerly e doe i O(m 3 Σ ) time. There exists lgorithm to do preprocessig i O(m Σ ). Altogether, ptter mtchig with DFA hs ru-time O(m Σ + ). This is fst ( Σ is costt) ut we c e fster! Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

20 Outlie 1 Strig Mtchig Itroductio Strig Mtchig with Fiite Automt Kuth-Morris-Prtt lgorithm Boyer-Moore Algorithm Ri-Krp Algorithm Suffix Trees Coclusio Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer 2018

21 Kuth-Morris-Prtt Motivtio Σ c Σ Use ew type of trsitio ( filure ): Use this trsitio oly if o other fits. Does ot cosume chrcter. With these rules, computtios of the utomto re determiistic. (But it is formlly ot vlid DFA.) Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

22 Kuth-Morris-Prtt Motivtio Σ c Σ Use ew type of trsitio ( filure ): Use this trsitio oly if o other fits. Does ot cosume chrcter. With these rules, computtios of the utomto re determiistic. (But it is formlly ot vlid DFA.) C store filure-fuctio i rry F [0..m 1] The filure rc from stte j leds to F [j 1] Give the filure-rry, we c esily test whether P is i T : Automto ccepts T if d oly if T cotis c Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

23 Kuth-Morris-Prtt Algorithm KMP(T, P), to retur the first mtch T : Strig of legth (text), P: Strig of legth m (ptter) 1. F filurearry(p) 2. i 0 // curret chrcter of T to prse 3. j 0 // curret stte tht we re i 4. while i < do 5. if P[j] = T [i] the 6. if j = m 1 the 7. retur i m + 1 //mtch 8. else 9. i i j j else // i. e. P[j] T [i] 12. if j > 0 the 13. j F [j 1] 14. else 15. i i retur FAIL // o mtch Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

24 Strig mtchig with KMP Exmple Exmple: T = c, P = c Σ c Σ T : c P : to stte 3 () () () to stte 3 () () () c q: , 4 5 3, (fter redig this chrcter) Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

25 Strig mtchig with KMP Filure-fuctio Let P the ptter to serch, of legth m. The stte of the utomto is i {0,..., m} Stte j represets the text tht hs ee prsed so fr eds with P[0..j 1], (d there is o loger prefix of P tht it eds with) Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

26 Strig mtchig with KMP Filure-fuctio Let P the ptter to serch, of legth m. The stte of the utomto is i {0,..., m} Stte j represets the text tht hs ee prsed so fr eds with P[0..j 1], (d there is o loger prefix of P tht it eds with) If the ext chrcter does ot exted ptter: The text tht hs ee prsed so fr eds with P[0...j 1] (Recll tht trsitio does ot cosume chrcter) Wt: The logest prefix of P tht is suffix of P[0..j 1] (ut exclude P[0..j 1] itself, sice tht leds to mismtch) The ew stte is the legth of tht prefix Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

27 Strig mtchig with KMP Filure-fuctio Let P the ptter to serch, of legth m. The stte of the utomto is i {0,..., m} Stte j represets the text tht hs ee prsed so fr eds with P[0..j 1], (d there is o loger prefix of P tht it eds with) If the ext chrcter does ot exted ptter: The text tht hs ee prsed so fr eds with P[0...j 1] (Recll tht trsitio does ot cosume chrcter) Wt: The logest prefix of P tht is suffix of P[0..j 1] (ut exclude P[0..j 1] itself, sice tht leds to mismtch) The ew stte is the legth of tht prefix Oe-setece descriptio: F [j] is the legth of the logest prefix of P[0..j] tht is suffix of P[1..j]. The filure-rc leds from stte j to stte F [j 1] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

28 KMP Filure Arry Exmple F [j] is the legth of the logest prefix of P[0..j] tht is suffix of P[1..j]. Cosider P = c j P[1..j] Prefixes of P logest F [j] 0 Λ Λ,,,,,,... Λ 0 1 Λ,,,,,,... Λ 0 2 Λ,,,,,, Λ,,,,,, Λ,,,,,, c Λ,,,,,,... Λ 0 6 c Λ,,,,,,... 1 This c clerly e computed i O(m 3 ) time, ut we c do etter! Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

29 Computig the Filure Arry filurearry(p) P: Strig of legth m (ptter) 1. F [0] 0 2. i 1 3. j 0 4. while i < m do 5. if P[i] = P[j] the 6. j j F [i] j 8. i i else if j > 0 the 10. j F [j 1] 11. else 12. F [i] i i + 1 Correctess-ide: F [ ] is defied vi ptter mtchig of P[1..i] i P. So KMP uses itself! Alredy-uilt prts of F [ ] re used to expd it. Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

30 KMP filure fuctio fst computtio P = c Σ Σ c Prse P[1..m 1] = c while ddig filure-rcs: Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

31 KMP filure fuctio fst computtio P = c Σ Σ c Prse P[1..m 1] = c while ddig filure-rcs: i 1 P[i] P[j] j 0 F [i] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

32 KMP filure fuctio fst computtio P = c Σ Σ c Prse P[1..m 1] = c while ddig filure-rcs: i 1 1 P[i] P[j] j 0 F [i] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

33 KMP filure fuctio fst computtio P = c Σ Σ c Prse P[1..m 1] = c while ddig filure-rcs: i P[i] P[j] j 0 0 F [i] 0 Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

34 KMP filure fuctio fst computtio P = c Σ Σ c Prse P[1..m 1] = c while ddig filure-rcs: i P[i] P[j] j 0 0 F [i] 0 Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

35 KMP filure fuctio fst computtio P = c Σ Σ c 6 7 Prse P[1..m 1] = c while ddig filure-rcs: i P[i] P[j] j F [i] 0 1 Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

36 KMP filure fuctio fst computtio P = c Σ Σ c 6 7 Prse P[1..m 1] = c while ddig filure-rcs: i P[i] P[j] j F [i] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

37 KMP filure fuctio fst computtio P = c Σ Σ c 6 7 Prse P[1..m 1] = c while ddig filure-rcs: i P[i] P[j] j F [i] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

38 KMP filure fuctio fst computtio P = c Σ Σ c 6 7 Prse P[1..m 1] = c while ddig filure-rcs: i P[i] c P[j] j F [i] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

39 KMP filure fuctio fst computtio P = c Σ Σ c 6 7 Prse P[1..m 1] = c while ddig filure-rcs: i P[i] c P[j] j F [i] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

40 KMP filure fuctio fst computtio P = c Σ Σ c 6 7 Prse P[1..m 1] = c while ddig filure-rcs: i P[i] c c P[j] j F [i] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

41 KMP filure fuctio fst computtio P = c Σ Σ c 6 7 Prse P[1..m 1] = c while ddig filure-rcs: i P[i] c c P[j] j F [i] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

42 KMP filure fuctio fst computtio P = c Σ Σ c 6 7 Prse P[1..m 1] = c while ddig filure-rcs: i P[i] c c c P[j] j c 0 F [i] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

43 KMP filure fuctio fst computtio P = c Σ Σ c 6 7 Prse P[1..m 1] = c while ddig filure-rcs: i P[i] c c c P[j] j c 0 1 F [i] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

44 KMP Rutime filurearry At ech itertio of the while loop, t lest oe of the followig hppes: 1 i icreses y oe, or 2 the idex i j icreses y t lest oe (F [j 1] < j) There re o more th 2m itertios of the while loop Ruig time: Θ(m) Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

45 KMP Rutime filurearry At ech itertio of the while loop, t lest oe of the followig hppes: 1 i icreses y oe, or 2 the idex i j icreses y t lest oe (F [j 1] < j) KMP There re o more th 2m itertios of the while loop Ruig time: Θ(m) filurearry c e computed i Θ(m) time At ech itertio of the while loop, t lest oe of the followig hppes: 1 i icreses y oe, or 2 the idex i j icreses y t lest oe (F [j 1] < j) There re o more th 2 itertios of the while loop Ruig time KMP ltogether: Θ( + m) Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

46 Outlie 1 Strig Mtchig Itroductio Strig Mtchig with Fiite Automt Kuth-Morris-Prtt lgorithm Boyer-Moore Algorithm Ri-Krp Algorithm Suffix Trees Coclusio Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer 2018

47 Boyer-Moore Algorithm Overview Bsed o three key ides: Reverse-order serchig: Compre P with susequece of T movig ckwrds Bd chrcter jumps: Whe mismtch occurs t T [i] = c, use loctio of c i P (if y) to elimite guesses. Good suffix jumps: Whe mismtch occurs, the use recetly see suffix of P to elimite guesses. Similr to filure rry i KMP. This gives two possile shifts (loctios of ext guess to try). Use the oe tht moves forwrd more. I prctice lrge prts of T will ot e looked t. Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

48 Boyer-Moore Algorithm BoyerMoore(T,P) 1. L lst occurrece rry computed from P 2. S good suffix rry computed from P 3. k 0 // curret guess 4. while k m 5. i k + m 1, j m 1 6. while j 0 d T [i] = P[j] the 7. i i 1 8. j j 1 9. if j = 1 retur k 10. else 11. k k + mx(1, j L[T [i]], m 1 S[j]) 12. retur FAIL L d S will e explied elow. Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

49 Bd chrcter exmples P = l d o T = w h e r e i s w l d o o P = m o o r e T = o y e r m o o r e Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

50 Bd chrcter exmples P = l d o T = w h e r e i s w l d o o o P = m o o r e T = o y e r m o o r e Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

51 Bd chrcter exmples P = l d o T = w h e r e i s w l d o o o o P = m o o r e T = o y e r m o o r e Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

52 Bd chrcter exmples P = l d o T = w h e r e i s w l d o o o d o P = m o o r e T = o y e r m o o r e Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

53 Bd chrcter exmples P = l d o T = w h e r e i s w l d o o o l d o P = m o o r e T = o y e r m o o r e Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

54 Bd chrcter exmples P = l d o T = w h e r e i s w l d o o o l d o P = m o o r e T = o y e r m o o r e Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

55 Bd chrcter exmples P = l d o T = w h e r e i s w l d o o o l d o 6 chrcters ot looked t P = m o o r e T = o y e r m o o r e Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

56 Bd chrcter exmples P = l d o T = w h e r e i s w l d o o o l d o 6 chrcters ot looked t P = m o o r e T = o y e r m o o r e e Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

57 Bd chrcter exmples P = l d o T = w h e r e i s w l d o o o l d o 6 chrcters ot looked t P = m o o r e T = o y e r m o o r e e (r) e Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

58 Bd chrcter exmples P = l d o T = w h e r e i s w l d o o o l d o 6 chrcters ot looked t P = m o o r e T = o y e r m o o r e e (r) e (m) e Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

59 Bd chrcter exmples P = l d o T = w h e r e i s w l d o o o l d o 6 chrcters ot looked t P = m o o r e T = o y e r m o o r e e (r) e (m) r e Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

60 Bd chrcter exmples P = l d o T = w h e r e i s w l d o o o l d o 6 chrcters ot looked t P = m o o r e T = o y e r m o o r e 4 chrcters ot looked t e (r) e (m) o o r e Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

61 Lst-Occurrece Fuctio Preprocess the ptter P d the lphet Σ Build the lst-occurrece fuctio L mppig Σ to itegers L(c) is defied s the lrgest idex i such tht P[i] = c or 1 if o such idex exists Exmple: P=moore c m o r e ll others L(c) T = o y e r m o o r e e k = 0, i = j = 4, T [i] = r, L[T [i]] = 3 k k = 1 (or igger) Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

62 Lst-Occurrece Fuctio Preprocess the ptter P d the lphet Σ Build the lst-occurrece fuctio L mppig Σ to itegers L(c) is defied s the lrgest idex i such tht P[i] = c or 1 if o such idex exists Exmple: P=moore c m o r e ll others L(c) T = o y e r m o o r e e k = 0, i = j = 4, T [i] = r, L[T [i]] = 3 k k = 1 (or igger) (r) Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

63 Good suffix exmples P = sells shells s h e i l s e l l s s h e l l s P = odetofood i l i k e f o o d f r o m m e x i c o Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

64 Good suffix exmples P = sells shells s h e i l s e l l s s h e l l s h e l l s P = odetofood i l i k e f o o d f r o m m e x i c o Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

65 Good suffix exmples P = sells shells s h e i l s e l l s s h e l l s h e l l s (e) (l) (l) (s) P = odetofood i l i k e f o o d f r o m m e x i c o o f o o d Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

66 Good suffix exmples P = sells shells s h e i l s e l l s s h e l l s h e l l s (e) (l) (l) (s) P = odetofood i l i k e f o o d f r o m m e x i c o o f o o d Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

67 Good suffix exmples P = sells shells s h e i l s e l l s s h e l l s h e l l s (e) (l) (l) (s) P = odetofood i l i k e f o o d f r o m m e x i c o o f o o d (o) (d) Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

68 Good suffix exmples P = sells shells s h e i l s e l l s s h e l l s h e l l s (e) (l) (l) (s) P = odetofood i l i k e f o o d f r o m m e x i c o o f o o d (o) (d) Crucil igrediet: logest suffix of P[i+1..m 1] tht occurs i P. Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

69 Good Suffix rry Precompute suffix skip rry S of size m: For 0 j < m, S[j] stores shift if serch filed t T [i] P[j] At this poit, hd T [i+1..k+m 1] = P[j+1..m 1] Also kow T [i] P[j] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

70 Good Suffix rry Precompute suffix skip rry S of size m: For 0 j < m, S[j] stores shift if serch filed t T [i] P[j] At this poit, hd T [i+1..k+m 1] = P[j+1..m 1] Also kow T [i] P[j] S[j] is the mximum idex l such tht OR P[j+1... m 1] is suffix of P[0... l] d P[j] P[l m+j+1] h e l l s (e) (l) (l) (s) P[0... l] is suffix of P[j+1,..., m 1] o f o o d (o) (d) Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

71 Good Suffix rry Precompute suffix skip rry S of size m: For 0 j < m, S[j] stores shift if serch filed t T [i] P[j] At this poit, hd T [i+1..k+m 1] = P[j+1..m 1] Also kow T [i] P[j] S[j] is the mximum idex l such tht OR P[j+1... m 1] is suffix of P[0... l] d P[j] P[l m+j+1] h e l l s (e) (l) (l) (s) P[0... l] is suffix of P[j+1,..., m 1] o f o o d (o) (d) Computle (similr to KMP filure fuctio) i Θ(m) time. You do ot eed to kow how to fid the vlues S[j], ut you must e le to fid the ext guess o exmples. Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

72 Boyer-Moore lgorithm coclusio Worst-cse ruig time O( + m + Σ ) if P is ot i T. This complexity is difficult to prove. Worst-cse ruig time O(m) if we wt to report ll occurreces (KMP c do i O( + m)) O typicl Eglish text the lgorithm proes pproximtely 25% of the chrcters i T Fster th KMP i prctice o Eglish text. Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

73 Outlie 1 Strig Mtchig Itroductio Strig Mtchig with Fiite Automt Kuth-Morris-Prtt lgorithm Boyer-Moore Algorithm Ri-Krp Algorithm Suffix Trees Coclusio Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer 2018

74 Ri-Krp Figerprit Algorithm Ide Ide: use hshig Compute hsh fuctio for ech text positio No explicit hsh tle: just compre with ptter hsh If mtch of the hsh vlue of the ptter d text positio foud, the compres the ptter with the sustrig y ive pproch Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

75 Ri-Krp Figerprit Algorithm Ide Ide: use hshig Compute hsh fuctio for ech text positio No explicit hsh tle: just compre with ptter hsh If mtch of the hsh vlue of the ptter d text positio foud, the compres the ptter with the sustrig y ive pproch Exmple: P: , T : Hsh fuctio: h(x) = x mod 97 gives h(p) = 95. Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

76 Ri-Krp Figerprit Algorithm Ide Ide: use hshig Compute hsh fuctio for ech text positio No explicit hsh tle: just compre with ptter hsh If mtch of the hsh vlue of the ptter d text positio foud, the compres the ptter with the sustrig y ive pproch Exmple: P: , T : Hsh fuctio: h(x) = x mod 97 gives h(p) = hsh-vlue 84 hsh-vlue 94 hsh-vlue 76 hsh-vlue 18 hsh-vlue 95 Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

77 Ri-Krp Figerprit Algorithm First Attempt Ri-Krp-Simple(T, P) 1. M suitle prime umer 2. h P compute-hsh-vlue(p[0..m 1], M) 3. for k 0 to m 4. h T compute-hsh-vlue(t [k..k+m 1], M) 5. if h T = h P the 6. if T [k..k+m 1] = P 7. retur foud t shift k 8. retur ot foud Never misses mtch sice h(k 1 ) h(k 2 ) implies k 1 k 2 h(t [k..k+m 1]) depeds o m chrcters, so ive computtio tkes Θ(m) time per shift Ruig time is Θ(m) for serch miss (how c we improve this?) Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

78 Ri-Krp Figerprit Algorithm Fst Rehsh The iitil hshes re clled figerprits. Crucil isight: We c updte these figerprits i costt time. Use previous hsh to compute ext hsh O(1) time per hsh, except first oe Exmple: Pre-compute: mod 97 = 9 Previous hsh: mod 97 = 76 Next hsh: mod 97 =?? Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

79 Ri-Krp Figerprit Algorithm Fst Rehsh The iitil hshes re clled figerprits. Crucil isight: We c updte these figerprits i costt time. Use previous hsh to compute ext hsh O(1) time per hsh, except first oe Exmple: Pre-compute: mod 97 = 9 Previous hsh: mod 97 = 76 Next hsh: mod 97 =?? Oservtio: mod 97= (41592 ( )) 10+6 mod97 = (76 (4 9 )) 10+6 mod97 = 406 mod97 = 18 Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

80 Ri-Krp Figerprit Algorithm Coclusio Ri-Krp-Fst(T, P) 1. M suitle prime umer 2. h P compute-hsh-vlue(p[0..m 1], M) 3. h T compute-hsh-vlue(t [0..m 1], M) 4. s 10 m 1 mod M 5. for k 0 to m 6. if h T = h P the 7. if T [k..k+m 1] = P 8. retur foud t shift k 9. if k < m the 10. h T ((h T T [k] s) 10 + T [k+m]) mod M 11. retur ot foud Choose tle size M t rdom to e huge prime Expected ruig time is O(m + ) Θ(m) worst-cse, ut this is (uelievly) ulikely Exteds to 2d ptters d other geerliztios Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

81 Outlie 1 Strig Mtchig Itroductio Strig Mtchig with Fiite Automt Kuth-Morris-Prtt lgorithm Boyer-Moore Algorithm Ri-Krp Algorithm Suffix Trees Coclusio Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer 2018

82 Tries of Suffixes d Suffix Trees Wht if we wt to serch for my ptters P withi the sme fixed text T? Ide: Preprocess the text T rther th the ptter P Oservtio: P is sustrig of T if d oly if P is prefix of some suffix of T. So wt to store ll suffixes of T i trie. To sve spce: Use compressed trie. Store suffixes implicitly vi idices ito T. This is clled suffix tree. Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

83 Trie of suffixes: Exmple T = hs suffixes {,,,,,,,,, Λ} Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

84 Tries of suffixes Store suffixes vi idices: T = T[9..9] T[5..9] T[8..9] T[7..9] T[6..9] T[3..9] T[4..9] T[1..9] T[0..9] T[2..9] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

85 Suffix tree Suffix tree: Compressed trie of suffixes T = 0 T[9..9] 1 3 T[5..9] 2 T[6..9] T[0..9] T[7..9] 3 T[3..9] T[1..9] 1 T[8..9] 2 T[4..9] T[2..9] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

86 Buildig Suffix Trees Text T hs chrcters d + 1 suffixes We c uild the suffix tree y isertig ech suffix of T ito compressed trie. This tkes time Θ( 2 ). There is wy to uild suffix tree of T i Θ() time. This is quite complicted d eyod the scope of the course. Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

87 Suffix Trees: Strig Mtchig Assume we hve suffix tree of text T. To serch for ptter P of legth m: We ssume tht P does ot hve the fil. P is the prefix of some suffix of T. I the ucompressed trie, serchig for P would e esy: P exists i T if d oly serch for P reches ode i the trie. I the suffix tree, serch for P util oe of the follow occurs: 1 If serch fils due to o such child the P is ot i T 2 If we rech ed of P, sy t ode v, the jump to lef l i sutree of v. (We presume tht suffix trees stores such shortcuts.) 3 Else we rech lef l = v while chrcters of P left. Either wy, left idex t l gives the shift tht we should check. This tkes O( P ) time. Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

88 Ptter Mtchig i Suffix Tree: Exmple T = P = 0 T[9..9] 1 3 T[5..9] 2 T[6..9] T[0..9] T[7..9] 3 o such child T[3..9] T[1..9] 1 T[8..9] 2 T[4..9] T[2..9] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

89 Ptter Mtchig i Suffix Tree: Exmple T = P = 0 T[9..9] 1 3 T[5..9] 2 T[6..9] T[0..9] T[7..9] 3 o such child T[3..9] T[1..9] 1 T[8..9] 2 T[4..9] T[2..9] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

90 Ptter Mtchig i Suffix Tree: Exmple T = P = 0 T[9..9] 1 3 T[5..9] 2 T[6..9] T[0..9] T[7..9] 3 T[3..9] T[1..9] 1 T[8..9] 2 T[4..9] T[2..9] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

91 Ptter Mtchig i Suffix Tree: Exmple T = P = 0 T[9..9] 1 3 T[5..9] 2 T[6..9] T[0..9] T[7..9] 3 T[3..9] T[1..9] 1 T[8..9] 2 T[4..9] T[2..9] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

92 Ptter Mtchig i Suffix Tree: Exmple T = P = 0 T[9..9] 1 3 T[5..9] 2 T[6..9] T[0..9] T[7..9] 3 T[3..9] T[1..9] 1 T[8..9] 2 T[4..9] T[2..9] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

93 Ptter Mtchig i Suffix Tree: Exmple T = P = 0 T[9..9] 1 3 T[5..9] 2 T[6..9] T[0..9] T[7..9] 3 T[3..9] T[1..9] 1 T[8..9] 2 T[4..9] T[2..9] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

94 Ptter Mtchig i Suffix Tree: Exmple T = P = rir 0 T[9..9] 1 3 T[5..9] 2 T[6..9] T[0..9] T[7..9] 3 T[3..9] T[1..9] 1 T[8..9] 2 T[4..9] T[2..9] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

95 Ptter Mtchig i Suffix Tree: Exmple T = P = rir 0 T[9..9] 1 3 T[5..9] 2 T[6..9] T[0..9] T[7..9] 3 T[3..9] T[1..9] 1 T[8..9] 2 T[4..9] T[2..9] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

96 Ptter Mtchig i Suffix Tree: Exmple T = P = rir 0 T[9..9] 1 3 T[5..9] 2 T[6..9] T[0..9] T[7..9] 3 T[3..9] T[1..9] 1 T[8..9] 2 T[4..9] T[2..9] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

97 Ptter Mtchig i Suffix Tree: Exmple T = P = rir 0 T[9..9] 1 3 T[5..9] 2 T[6..9] T[0..9] T[7..9] 3 T[3..9] T[1..9] 1 T[8..9] 2 T[4..9] T[2..9] Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

98 Outlie 1 Strig Mtchig Itroductio Strig Mtchig with Fiite Automt Kuth-Morris-Prtt lgorithm Boyer-Moore Algorithm Ri-Krp Algorithm Suffix Trees Coclusio Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer 2018

99 Strig Mtchig Coclusio Brute- Force DFA KMP BM RK Preproc. O(m Σ ) O(m) O(m + Σ ) O(m) Serch O() O( + m) O(m) O() O() time (ofte etter) (expected) Extr spce Suffix trees O( 2 ) ( O()) O(m) O(m Σ ) O(m) O(m + Σ ) O(1) O() Biedl, Lctot, Sepehri, Wild (SCS, UW) CS240 Module 9 Witer / 42

Module 9: Tries and String Matching

Module 9: Tries and String Matching Module 9: Tries nd String Mtching CS 240 - Dt Structures nd Dt Mngement Sjed Hque Veronik Irvine Tylor Smith Bsed on lecture notes by mny previous cs240 instructors Dvid R. Cheriton School of Computer

More information

Module 9: Tries and String Matching

Module 9: Tries and String Matching Module 9: Tries nd String Mtching CS 240 - Dt Structures nd Dt Mngement Sjed Hque Veronik Irvine Tylor Smith Bsed on lecture notes by mny previous cs240 instructors Dvid R. Cheriton School of Computer

More information

Content. Languages, Alphabets and Strings. Operations on Strings. a ab abba baba. aaabbbaaba b 5. Languages. A language is a set of strings

Content. Languages, Alphabets and Strings. Operations on Strings. a ab abba baba. aaabbbaaba b 5. Languages. A language is a set of strings CD5560 FABER Forml guges, Automt d Models of Computtio ecture Mälrdle Uiversity 006 Cotet guges, Alphets d Strigs Strigs & Strig Opertios guges & guge Opertios Regulr Expressios Fiite Automt, FA Determiistic

More information

Introduction to Computational Molecular Biology. Suffix Trees

Introduction to Computational Molecular Biology. Suffix Trees 18.417 Itroductio to Computtiol Moleculr Biology Lecture 11: October 14, 004 Scribe: Athich Muthitchroe Lecturer: Ross Lippert Editor: Toy Scelfo Suffix Trees This is oe of the most complicted dt structures

More information

Course Material. CS Lecture 1 Deterministic Finite Automata. Grading and Policies. Workload. Website:http://www.cs.colostate.

Course Material. CS Lecture 1 Deterministic Finite Automata. Grading and Policies. Workload. Website:http://www.cs.colostate. Course Mteril CS 301 - Lecture 1 Determiistic Fiite Automt Fll 2008 Wesite:http://www.cs.colostte.edu/~cs301 Syllus, Outlie, Grdig Policies Homework d Slides Istructor: D Mssey Office hours: 2-3pm Tues

More information

Module 9: Tries and String Matching

Module 9: Tries and String Matching Module 9: Tries and String Matching CS 240 - Data Structures and Data Management Sajed Haque Veronika Irvine Taylor Smith Based on lecture notes by many previous cs240 instructors David R. Cheriton School

More information

Fingerprint idea. Assume:

Fingerprint idea. Assume: Fingerprint ide Assume: We cn compute fingerprint f(p) of P in O(m) time. If f(p) f(t[s.. s+m 1]), then P T[s.. s+m 1] We cn compre fingerprints in O(1) We cn compute f = f(t[s+1.. s+m]) from f(t[s.. s+m

More information

Section 6.3: Geometric Sequences

Section 6.3: Geometric Sequences 40 Chpter 6 Sectio 6.: Geometric Sequeces My jobs offer ul cost-of-livig icrese to keep slries cosistet with ifltio. Suppose, for exmple, recet college grdute fids positio s sles mger erig ul slry of $6,000.

More information

Week 13 Notes: 1) Riemann Sum. Aim: Compute Area Under a Graph. Suppose we want to find out the area of a graph, like the one on the right:

Week 13 Notes: 1) Riemann Sum. Aim: Compute Area Under a Graph. Suppose we want to find out the area of a graph, like the one on the right: Week 1 Notes: 1) Riem Sum Aim: Compute Are Uder Grph Suppose we wt to fid out the re of grph, like the oe o the right: We wt to kow the re of the red re. Here re some wys to pproximte the re: We cut the

More information

Section IV.6: The Master Method and Applications

Section IV.6: The Master Method and Applications Sectio IV.6: The Mster Method d Applictios Defiitio IV.6.1: A fuctio f is symptoticlly positive if d oly if there exists rel umer such tht f(x) > for ll x >. A cosequece of this defiitio is tht fuctio

More information

B. Examples 1. Finite Sums finite sums are an example of Riemann Sums in which each subinterval has the same length and the same x i

B. Examples 1. Finite Sums finite sums are an example of Riemann Sums in which each subinterval has the same length and the same x i Mth 06 Clculus Sec. 5.: The Defiite Itegrl I. Riem Sums A. Def : Give y=f(x):. Let f e defied o closed itervl[,].. Prtitio [,] ito suitervls[x (i-),x i ] of legth Δx i = x i -x (i-). Let P deote the prtitio

More information

Applied Databases. Sebastian Maneth. Lecture 16 Suffix Array, Burrows-Wheeler Transform. University of Edinburgh - March 10th, 2016

Applied Databases. Sebastian Maneth. Lecture 16 Suffix Array, Burrows-Wheeler Transform. University of Edinburgh - March 10th, 2016 Applied Dtbses Lecture 16 Suffix Arry, Burrows-Wheeler Trsform Sebsti Meth Uiversity of Ediburgh - Mrch 10th, 2016 2 Outlie 1. Suffix Arry 2. Burrows-Wheeler Trsform 3 Olie Strig-Mtchig how c we do Horspool

More information

Where did dynamic programming come from?

Where did dynamic programming come from? Where did dynmic progrmming come from? String lgorithms Dvid Kuchk cs302 Spring 2012 Richrd ellmn On the irth of Dynmic Progrmming Sturt Dreyfus http://www.eng.tu.c.il/~mi/cd/ or50/1526-5463-2002-50-01-0048.pdf

More information

Pairwise alignment is used to detect homologies between different protein or DNA sequences, either as global or local alignments.

Pairwise alignment is used to detect homologies between different protein or DNA sequences, either as global or local alignments. 5 BLAST d Aho-Corsick This expositio ws prepred y Clemes Gröpl, sed o versios y Diel Huso d Kut Reiert. It is sed o the followig sources, which re ll recommeded redig: D Gusfield: Algorithms o Strigs,

More information

General properties of definite integrals

General properties of definite integrals Roerto s Notes o Itegrl Clculus Chpter 4: Defiite itegrls d the FTC Sectio Geerl properties of defiite itegrls Wht you eed to kow lredy: Wht defiite Riem itegrl is. Wht you c ler here: Some key properties

More information

Applied Databases. Sebastian Maneth. Lecture 16 Suffix Array, Burrows-Wheeler Transform. University of Edinburgh - March 16th, 2017

Applied Databases. Sebastian Maneth. Lecture 16 Suffix Array, Burrows-Wheeler Transform. University of Edinburgh - March 16th, 2017 Applied Dtbses Lecture 16 Suffix Arry, Burrows-Wheeler Trsform Sebsti Meth Uiversity of Ediburgh - Mrch 16th, 2017 Outlie 2 1. Suffix Arry 2. Burrows-Wheeler Trsform Outlie 3 1. Suffix Arry 2. Burrows-Wheeler

More information

Similar idea to multiplication in N, C. Divide and conquer approach provides unexpected improvements. Naïve matrix multiplication

Similar idea to multiplication in N, C. Divide and conquer approach provides unexpected improvements. Naïve matrix multiplication Next. Covered bsics of simple desig techique (Divided-coquer) Ch. of the text.. Next, Strsse s lgorithm. Lter: more desig d coquer lgorithms: MergeSort. Solvig recurreces d the Mster Theorem. Similr ide

More information

Taylor Polynomials. The Tangent Line. (a, f (a)) and has the same slope as the curve y = f (x) at that point. It is the best

Taylor Polynomials. The Tangent Line. (a, f (a)) and has the same slope as the curve y = f (x) at that point. It is the best Tylor Polyomils Let f () = e d let p() = 1 + + 1 + 1 6 3 Without usig clcultor, evlute f (1) d p(1) Ok, I m still witig With little effort it is possible to evlute p(1) = 1 + 1 + 1 (144) + 6 1 (178) =

More information

Approximate Integration

Approximate Integration Study Sheet (7.7) Approimte Itegrtio I this sectio, we will ler: How to fid pproimte vlues of defiite itegrls. There re two situtios i which it is impossile to fid the ect vlue of defiite itegrl. Situtio:

More information

Lecture 4 Recursive Algorithm Analysis. Merge Sort Solving Recurrences The Master Theorem

Lecture 4 Recursive Algorithm Analysis. Merge Sort Solving Recurrences The Master Theorem Lecture 4 Recursive Algorithm Alysis Merge Sort Solvig Recurreces The Mster Theorem Merge Sort MergeSortA, left, right) { if left < right) { mid = floorleft + right) / 2); MergeSortA, left, mid); MergeSortA,

More information

Data Compression Techniques (Spring 2012) Model Solutions for Exercise 4

Data Compression Techniques (Spring 2012) Model Solutions for Exercise 4 58487 Dt Compressio Tehiques (Sprig 0) Moel Solutios for Exerise 4 If you hve y fee or orretios, plese ott jro.lo t s.helsii.fi.. Prolem: Let T = Σ = {,,, }. Eoe T usig ptive Huffm oig. Solutio: R 4 U

More information

Merge Sort. Outline and Reading. Divide-and-Conquer. Divide-and-conquer paradigm ( 4.1.1) Merge-sort ( 4.1.1)

Merge Sort. Outline and Reading. Divide-and-Conquer. Divide-and-conquer paradigm ( 4.1.1) Merge-sort ( 4.1.1) Merge Sort 7 2 9 4 2 4 7 9 7 2 2 7 9 4 4 9 7 7 2 2 9 9 4 4 Merge Sort versio 1.3 1 Outlie d Redig Divide-d-coquer prdigm ( 4.1.1 Merge-sort ( 4.1.1 Algorithm Mergig two sorted sequeces Merge-sort tree

More information

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014 CS125 Lecture 12 Fll 2014 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple

More information

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont. NFA DFA Exmple 3 CMSC 330: Orgniztion of Progrmming Lnguges NFA {B,D,E {A,E {C,D {E Finite Automt, con't. R = { {A,E, {B,D,E, {C,D, {E 2 Equivlence of DFAs nd NFAs Any string from {A to either {D or {CD

More information

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Lecture 17

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Lecture 17 CS 70 Discrete Mthemtics d Proility Theory Sprig 206 Ro d Wlrd Lecture 7 Vrice We hve see i the previous ote tht if we toss coi times with is p, the the expected umer of heds is p. Wht this mes is tht

More information

The total number of permutations of S is n!. We denote the set of all permutations of S by

The total number of permutations of S is n!. We denote the set of all permutations of S by DETERMINNTS. DEFINITIONS Def: Let S {,,, } e the set of itegers from to, rrged i scedig order. rerrgemet jjj j of the elemets of S is clled permuttio of S. S. The totl umer of permuttios of S is!. We deote

More information

Fast Fourier Transform 1) Legendre s Interpolation 2) Vandermonde Matrix 3) Roots of Unity 4) Polynomial Evaluation

Fast Fourier Transform 1) Legendre s Interpolation 2) Vandermonde Matrix 3) Roots of Unity 4) Polynomial Evaluation Algorithm Desig d Alsis Victor Admchi CS 5-45 Sprig 4 Lecture 3 J 7, 4 Cregie Mello Uiversit Outlie Fst Fourier Trsform ) Legedre s Iterpoltio ) Vdermode Mtri 3) Roots of Uit 4) Polomil Evlutio Guss (777

More information

0 otherwise. sin( nx)sin( kx) 0 otherwise. cos( nx) sin( kx) dx 0 for all integers n, k.

0 otherwise. sin( nx)sin( kx) 0 otherwise. cos( nx) sin( kx) dx 0 for all integers n, k. . Computtio of Fourier Series I this sectio, we compute the Fourier coefficiets, f ( x) cos( x) b si( x) d b, i the Fourier series To do this, we eed the followig result o the orthogolity of the trigoometric

More information

is an ordered list of numbers. Each number in a sequence is a term of a sequence. n-1 term

is an ordered list of numbers. Each number in a sequence is a term of a sequence. n-1 term Mthemticl Ptters. Arithmetic Sequeces. Arithmetic Series. To idetify mthemticl ptters foud sequece. To use formul to fid the th term of sequece. To defie, idetify, d pply rithmetic sequeces. To defie rithmetic

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 CMSC 330 1 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All exmples so fr Nondeterministic

More information

Review of the Riemann Integral

Review of the Riemann Integral Chpter 1 Review of the Riem Itegrl This chpter provides quick review of the bsic properties of the Riem itegrl. 1.0 Itegrls d Riem Sums Defiitio 1.0.1. Let [, b] be fiite, closed itervl. A prtitio P of

More information

Applications of Regular Closure

Applications of Regular Closure Applictios of Regulr Closure 1 The itersectio of cotext-free lguge d regulr lguge is cotext-free lguge L1 L2 cotext free regulr Regulr Closure L1 L 2 cotext-free 2 Liz 6 th, sectio 8.2, exple 8.7, pge

More information

ICS141: Discrete Mathematics for Computer Science I

ICS141: Discrete Mathematics for Computer Science I ICS4: Discrete Mthemtics for Computer Sciece I Dept. Iformtio & Computer Sci., J Stelovsky sed o slides y Dr. Bek d Dr. Still Origils y Dr. M. P. Frk d Dr. J.L. Gross Provided y McGrw-Hill 3- Quiz. gcd(84,96).

More information

arxiv: v1 [cs.ds] 1 Jul 2016

arxiv: v1 [cs.ds] 1 Jul 2016 Represetig Ptter Mtchig Algorithms by Polyomil-Size Automt Tobis Mrschll Noemi E. Pssig rxiv:1607.00138v1 [cs.ds] 1 Jul 2016 Abstrct for fixed S, fixed, d A BM,BMH,B(N)DM} i polyomil time for very geerl

More information

10.5 Power Series. In this section, we are going to start talking about power series. A power series is a series of the form

10.5 Power Series. In this section, we are going to start talking about power series. A power series is a series of the form 0.5 Power Series I the lst three sectios, we ve spet most of tht time tlkig bout how to determie if series is coverget or ot. Now it is time to strt lookig t some specific kids of series d we will evetully

More information

Numbers (Part I) -- Solutions

Numbers (Part I) -- Solutions Ley College -- For AMATYC SML Mth Competitio Cochig Sessios v.., [/7/00] sme s /6/009 versio, with presettio improvemets Numbers Prt I) -- Solutios. The equtio b c 008 hs solutio i which, b, c re distict

More information

Limit of a function:

Limit of a function: - Limit of fuctio: We sy tht f ( ) eists d is equl with (rel) umer L if f( ) gets s close s we wt to L if is close eough to (This defiitio c e geerlized for L y syig tht f( ) ecomes s lrge (or s lrge egtive

More information

Handout #2. Introduction to Matrix: Matrix operations & Geometric meaning

Handout #2. Introduction to Matrix: Matrix operations & Geometric meaning Hdout # Title: FAE Course: Eco 8/ Sprig/5 Istructor: Dr I-Mig Chiu Itroductio to Mtrix: Mtrix opertios & Geometric meig Mtrix: rectgulr rry of umers eclosed i pretheses or squre rckets It is covetiolly

More information

Chapter 7 Infinite Series

Chapter 7 Infinite Series MA Ifiite Series Asst.Prof.Dr.Supree Liswdi Chpter 7 Ifiite Series Sectio 7. Sequece A sequece c be thought of s list of umbers writte i defiite order:,,...,,... 2 The umber is clled the first term, 2

More information

MTH 146 Class 16 Notes

MTH 146 Class 16 Notes MTH 46 Clss 6 Notes 0.4- Cotiued Motivtio: We ow cosider the rc legth of polr curve. Suppose we wish to fid the legth of polr curve curve i terms of prmetric equtios s: r f where b. We c view the cos si

More information

1 Nondeterministic Finite Automata

1 Nondeterministic Finite Automata 1 Nondeterministic Finite Automt Suppose in life, whenever you hd choice, you could try oth possiilities nd live your life. At the end, you would go ck nd choose the one tht worked out the est. Then you

More information

( ) k ( ) 1 T n 1 x = xk. Geometric series obtained directly from the definition. = 1 1 x. See also Scalars 9.1 ADV-1: lim n.

( ) k ( ) 1 T n 1 x = xk. Geometric series obtained directly from the definition. = 1 1 x. See also Scalars 9.1 ADV-1: lim n. Sclrs-9.0-ADV- Algebric Tricks d Where Tylor Polyomils Come From 207.04.07 A.docx Pge of Algebric tricks ivolvig x. You c use lgebric tricks to simplify workig with the Tylor polyomils of certi fuctios..

More information

Convergence rates of approximate sums of Riemann integrals

Convergence rates of approximate sums of Riemann integrals Covergece rtes of pproximte sums of Riem itegrls Hiroyuki Tski Grdute School of Pure d Applied Sciece, Uiversity of Tsuku Tsuku Irki 5-857 Jp tski@mth.tsuku.c.jp Keywords : covergece rte; Riem sum; Riem

More information

Nondeterminism and Nodeterministic Automata

Nondeterminism and Nodeterministic Automata Nondeterminism nd Nodeterministic Automt 61 Nondeterminism nd Nondeterministic Automt The computtionl mchine models tht we lerned in the clss re deterministic in the sense tht the next move is uniquely

More information

Laws of Integral Indices

Laws of Integral Indices A Lws of Itegrl Idices A. Positive Itegrl Idices I, is clled the se, is clled the idex lso clled the expoet. mes times.... Exmple Simplify 5 6 c Solutio 8 5 6 c 6 Exmple Simplify Solutio The results i

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb. CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2 CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

4. When is the particle speeding up? Why? 5. When is the particle slowing down? Why?

4. When is the particle speeding up? Why? 5. When is the particle slowing down? Why? AB CALCULUS: 5.3 Positio vs Distce Velocity vs. Speed Accelertio All the questios which follow refer to the grph t the right.. Whe is the prticle movig t costt speed?. Whe is the prticle movig to the right?

More information

8.1 Arc Length. What is the length of a curve? How can we approximate it? We could do it following the pattern we ve used before

8.1 Arc Length. What is the length of a curve? How can we approximate it? We could do it following the pattern we ve used before 8.1 Arc Legth Wht is the legth of curve? How c we pproximte it? We could do it followig the ptter we ve used efore Use sequece of icresigly short segmets to pproximte the curve: As the segmets get smller

More information

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4 Intermedite Mth Circles Wednesdy, Novemer 14, 2018 Finite Automt II Nickols Rollick nrollick@uwterloo.c Regulr Lnguges Lst time, we were introduced to the ide of DFA (deterministic finite utomton), one

More information

PROGRESSIONS AND SERIES

PROGRESSIONS AND SERIES PROGRESSIONS AND SERIES A sequece is lso clled progressio. We ow study three importt types of sequeces: () The Arithmetic Progressio, () The Geometric Progressio, () The Hrmoic Progressio. Arithmetic Progressio.

More information

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016 CS125 Lecture 12 Fll 2016 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple

More information

Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Divide-and-Conquer

Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Divide-and-Conquer Presettio for use with the textook, Algorithm Desig d Applictios, y M. T. Goodrich d R. Tmssi, Wiley, 25 Divide-d-Coquer Divide-d-Coquer Divide-d coquer is geerl lgorithm desig prdigm: Divide: divide the

More information

GRAPHING LINEAR EQUATIONS. Linear Equations. x l ( 3,1 ) _x-axis. Origin ( 0, 0 ) Slope = change in y change in x. Equation for l 1.

GRAPHING LINEAR EQUATIONS. Linear Equations. x l ( 3,1 ) _x-axis. Origin ( 0, 0 ) Slope = change in y change in x. Equation for l 1. GRAPHING LINEAR EQUATIONS Qudrt II Qudrt I ORDERED PAIR: The first umer i the ordered pir is the -coordite d the secod umer i the ordered pir is the y-coordite. (, ) Origi ( 0, 0 ) _-is Lier Equtios Qudrt

More information

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014 CMPSCI 250: Introduction to Computtion Lecture #31: Wht DFA s Cn nd Cn t Do Dvid Mix Brrington 9 April 2014 Wht DFA s Cn nd Cn t Do Deterministic Finite Automt Forml Definition of DFA s Exmples of DFA

More information

Linford 1. Kyle Linford. Math 211. Honors Project. Theorems to Analyze: Theorem 2.4 The Limit of a Function Involving a Radical (A4)

Linford 1. Kyle Linford. Math 211. Honors Project. Theorems to Analyze: Theorem 2.4 The Limit of a Function Involving a Radical (A4) Liford 1 Kyle Liford Mth 211 Hoors Project Theorems to Alyze: Theorem 2.4 The Limit of Fuctio Ivolvig Rdicl (A4) Theorem 2.8 The Squeeze Theorem (A5) Theorem 2.9 The Limit of Si(x)/x = 1 (p. 85) Theorem

More information

1.3 Continuous Functions and Riemann Sums

1.3 Continuous Functions and Riemann Sums mth riem sums, prt 0 Cotiuous Fuctios d Riem Sums I Exmple we sw tht lim Lower() = lim Upper() for the fuctio!! f (x) = + x o [0, ] This is o ccidet It is exmple of the followig theorem THEOREM Let f be

More information

Advanced Algorithmic Problem Solving Le 6 Math and Search

Advanced Algorithmic Problem Solving Le 6 Math and Search Advced Algorithmic Prolem Solvig Le Mth d Serch Fredrik Heitz Dept of Computer d Iformtio Sciece Liköpig Uiversity Outlie Arithmetic (l. d.) Solvig lier equtio systems (l. d.) Chiese remider theorem (l.5

More information

Minimal DFA. minimal DFA for L starting from any other

Minimal DFA. minimal DFA for L starting from any other Miniml DFA Among the mny DFAs ccepting the sme regulr lnguge L, there is exctly one (up to renming of sttes) which hs the smllest possile numer of sttes. Moreover, it is possile to otin tht miniml DFA

More information

Designing finite automata II

Designing finite automata II Designing finite utomt II Prolem: Design DFA A such tht L(A) consists of ll strings of nd which re of length 3n, for n = 0, 1, 2, (1) Determine wht to rememer out the input string Assign stte to ech of

More information

Error-free compression

Error-free compression Error-free compressio Useful i pplictio where o loss of iformtio is tolerble. This mybe due to ccurcy requiremets, legl requiremets, or less th perfect qulity of origil imge. Compressio c be chieved by

More information

Homework 3 Solutions

Homework 3 Solutions CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 3 Solutions 1. Give NFAs with the specified numer of sttes recognizing ech of the following lnguges. In ll cses, the lphet is Σ = {,1}.

More information

 n. A Very Interesting Example + + = d. + x3. + 5x4. math 131 power series, part ii 7. One of the first power series we examined was. 2!

 n. A Very Interesting Example + + = d. + x3. + 5x4. math 131 power series, part ii 7. One of the first power series we examined was. 2! mth power series, prt ii 7 A Very Iterestig Emple Oe of the first power series we emied ws! + +! + + +!! + I Emple 58 we used the rtio test to show tht the itervl of covergece ws (, ) Sice the series coverges

More information

Lexical Analysis Part III

Lexical Analysis Part III Lexicl Anlysis Prt III Chpter 3: Finite Automt Slides dpted from : Roert vn Engelen, Florid Stte University Alex Aiken, Stnford University Design of Lexicl Anlyzer Genertor Trnslte regulr expressions to

More information

n 2 + 3n + 1 4n = n2 + 3n + 1 n n 2 = n + 1

n 2 + 3n + 1 4n = n2 + 3n + 1 n n 2 = n + 1 Ifiite Series Some Tests for Divergece d Covergece Divergece Test: If lim u or if the limit does ot exist, the series diverget. + 3 + 4 + 3 EXAMPLE: Show tht the series diverges. = u = + 3 + 4 + 3 + 3

More information

CS 331 Design and Analysis of Algorithms. -- Divide and Conquer. Dr. Daisy Tang

CS 331 Design and Analysis of Algorithms. -- Divide and Conquer. Dr. Daisy Tang CS 33 Desig d Alysis of Algorithms -- Divide d Coquer Dr. Disy Tg Divide-Ad-Coquer Geerl ide: Divide problem ito subproblems of the sme id; solve subproblems usig the sme pproh, d ombie prtil solutios,

More information

Definite Integral. The Left and Right Sums

Definite Integral. The Left and Right Sums Clculus Li Vs Defiite Itegrl. The Left d Right Sums The defiite itegrl rises from the questio of fidig the re betwee give curve d x-xis o itervl. The re uder curve c be esily clculted if the curve is give

More information

Chapter 10: The Z-Transform Adapted from: Lecture notes from MIT, Binghamton University Hamid R. Rabiee Arman Sepehr Fall 2010

Chapter 10: The Z-Transform Adapted from: Lecture notes from MIT, Binghamton University Hamid R. Rabiee Arman Sepehr Fall 2010 Sigls & Systems Chpter 0: The Z-Trsform Adpted from: Lecture otes from MIT, Bighmto Uiversity Hmid R. Riee Arm Sepehr Fll 00 Lecture 5 Chpter 0 Outlie Itroductio to the -Trsform Properties of the ROC of

More information

Formal languages, automata, and theory of computation

Formal languages, automata, and theory of computation Mälrdlen University TEN1 DVA337 2015 School of Innovtion, Design nd Engineering Forml lnguges, utomt, nd theory of computtion Thursdy, Novemer 5, 14:10-18:30 Techer: Dniel Hedin, phone 021-107052 The exm

More information

Mathacle. PSet Stats, Concepts In Statistics Level Number Name: Date:

Mathacle. PSet Stats, Concepts In Statistics Level Number Name: Date: APPENDEX I. THE RAW ALGEBRA IN STATISTICS A I-1. THE INEQUALITY Exmple A I-1.1. Solve ech iequlity. Write the solutio i the itervl ottio..) 2 p - 6 p -8.) 2x- 3 < 5 Solutio:.). - 4 p -8 p³ 2 or pî[2, +

More information

lecture 16: Introduction to Least Squares Approximation

lecture 16: Introduction to Least Squares Approximation 97 lecture 16: Itroductio to Lest Squres Approximtio.4 Lest squres pproximtio The miimx criterio is ituitive objective for pproximtig fuctio. However, i my cses it is more ppelig (for both computtio d

More information

Formal Languages The Pumping Lemma for CFLs

Formal Languages The Pumping Lemma for CFLs Forl Lguges The Pupig Le for CFLs Review: pupig le for regulr lguges Tke ifiite cotext-free lguge Geertes ifiite uer of differet strigs Exple: 3 I derivtio of log strig, vriles re repeted derivtio: 4 Derivtio

More information

( a n ) converges or diverges.

( a n ) converges or diverges. Chpter Ifiite Series Pge of Sectio E Rtio Test Chpter : Ifiite Series By the ed of this sectio you will be ble to uderstd the proof of the rtio test test series for covergece by pplyig the rtio test pprecite

More information

Review of CFGs and Parsing I Context-free Languages and Grammars. Winter 2014 Costas Busch - RPI 1

Review of CFGs and Parsing I Context-free Languages and Grammars. Winter 2014 Costas Busch - RPI 1 Review of CFGs d Prsig I Cotext-free Lguges d Grmmrs Witer 2014 Costs Busch - RPI 1 Cotext-Free Lguges { b : { ww } 0} R Regulr Lguges *b* ( b) * Witer 2014 Costs Busch - RPI 2 Cotext-Free Lguges Cotext-Free

More information

Geometric Sequences. Geometric Sequence. Geometric sequences have a common ratio.

Geometric Sequences. Geometric Sequence. Geometric sequences have a common ratio. s A geometric sequece is sequece such tht ech successive term is obtied from the previous term by multiplyig by fixed umber clled commo rtio. Exmples, 6, 8,, 6,..., 0, 0, 0, 80,... Geometric sequeces hve

More information

MA123, Chapter 9: Computing some integrals (pp )

MA123, Chapter 9: Computing some integrals (pp ) MA13, Chpter 9: Computig some itegrls (pp. 189-05) Dte: Chpter Gols: Uderstd how to use bsic summtio formuls to evlute more complex sums. Uderstd how to compute its of rtiol fuctios t ifiity. Uderstd how

More information

b a 2 ((g(x))2 (f(x)) 2 dx

b a 2 ((g(x))2 (f(x)) 2 dx Clc II Fll 005 MATH Nme: T3 Istructios: Write swers to problems o seprte pper. You my NOT use clcultors or y electroic devices or otes of y kid. Ech st rred problem is extr credit d ech is worth 5 poits.

More information

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1 Chpter Five: Nondeterministic Finite Automt Forml Lnguge, chpter 5, slide 1 1 A DFA hs exctly one trnsition from every stte on every symol in the lphet. By relxing this requirement we get relted ut more

More information

NFAs continued, Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages Algorithms & Models of Computtion CS/ECE 374, Fll 2017 NFAs continued, Closure Properties of Regulr Lnguges Lecture 5 Tuesdy, Septemer 12, 2017 Sriel Hr-Peled (UIUC) CS374 1 Fll 2017 1 / 31 Regulr Lnguges,

More information

INTEGRATION IN THEORY

INTEGRATION IN THEORY CHATER 5 INTEGRATION IN THEORY 5.1 AREA AROXIMATION 5.1.1 SUMMATION NOTATION Fibocci Sequece First, exmple of fmous sequece of umbers. This is commoly ttributed to the mthemtici Fibocci of is, lthough

More information

Fig. 1. I a. V ag I c. I n. V cg. Z n Z Y. I b. V bg

Fig. 1. I a. V ag I c. I n. V cg. Z n Z Y. I b. V bg ymmetricl Compoets equece impedces Although the followig focuses o lods, the results pply eqully well to lies, or lies d lods. Red these otes together with sectios.6 d.9 of text. Cosider the -coected lced

More information

Finite Automata-cont d

Finite Automata-cont d Automt Theory nd Forml Lnguges Professor Leslie Lnder Lecture # 6 Finite Automt-cont d The Pumping Lemm WEB SITE: http://ingwe.inghmton.edu/ ~lnder/cs573.html Septemer 18, 2000 Exmple 1 Consider L = {ww

More information

Vectors. Vectors in Plane ( 2

Vectors. Vectors in Plane ( 2 Vectors Vectors i Ple ( ) The ide bout vector is to represet directiol force Tht mes tht every vector should hve two compoets directio (directiol slope) d mgitude (the legth) I the ple we preset vector

More information

Convergence rates of approximate sums of Riemann integrals

Convergence rates of approximate sums of Riemann integrals Jourl of Approximtio Theory 6 (9 477 49 www.elsevier.com/locte/jt Covergece rtes of pproximte sums of Riem itegrls Hiroyuki Tski Grdute School of Pure d Applied Sciece, Uiversity of Tsukub, Tsukub Ibrki

More information

The Definite Riemann Integral

The Definite Riemann Integral These otes closely follow the presettio of the mteril give i Jmes Stewrt s textook Clculus, Cocepts d Cotexts (d editio). These otes re iteded primrily for i-clss presettio d should ot e regrded s sustitute

More information

POWER SERIES R. E. SHOWALTER

POWER SERIES R. E. SHOWALTER POWER SERIES R. E. SHOWALTER. sequeces We deote by lim = tht the limit of the sequece { } is the umber. By this we me tht for y ε > 0 there is iteger N such tht < ε for ll itegers N. This mkes precise

More information

The Basic Properties of the Integral

The Basic Properties of the Integral The Bsic Properties of the Itegrl Whe we compute the derivtive of complicted fuctio, like x + six, we usully use differetitio rules, like d [f(x)+g(x)] d f(x)+ d g(x), to reduce the computtio dx dx dx

More information

Recurrece reltio & Recursio 9 Chpter 3 Recurrece reltio & Recursio Recurrece reltio : A recurrece is equtio or iequlity tht describes fuctio i term of itself with its smller iputs. T T The problem of size

More information

INTEGRATION TECHNIQUES (TRIG, LOG, EXP FUNCTIONS)

INTEGRATION TECHNIQUES (TRIG, LOG, EXP FUNCTIONS) Mthemtics Revisio Guides Itegrtig Trig, Log d Ep Fuctios Pge of MK HOME TUITION Mthemtics Revisio Guides Level: AS / A Level AQA : C Edecel: C OCR: C OCR MEI: C INTEGRATION TECHNIQUES (TRIG, LOG, EXP FUNCTIONS)

More information

CS 267: Automated Verification. Lecture 8: Automata Theoretic Model Checking. Instructor: Tevfik Bultan

CS 267: Automated Verification. Lecture 8: Automata Theoretic Model Checking. Instructor: Tevfik Bultan CS 267: Automted Verifiction Lecture 8: Automt Theoretic Model Checking Instructor: Tevfik Bultn LTL Properties Büchi utomt [Vrdi nd Wolper LICS 86] Büchi utomt: Finite stte utomt tht ccept infinite strings

More information

EVALUATING DEFINITE INTEGRALS

EVALUATING DEFINITE INTEGRALS Chpter 4 EVALUATING DEFINITE INTEGRALS If the defiite itegrl represets re betwee curve d the x-xis, d if you c fid the re by recogizig the shpe of the regio, the you c evlute the defiite itegrl. Those

More information

Let's start with an example:

Let's start with an example: Finite Automt Let's strt with n exmple: Here you see leled circles tht re sttes, nd leled rrows tht re trnsitions. One of the sttes is mrked "strt". One of the sttes hs doule circle; this is terminl stte

More information

Lecture 08: Feb. 08, 2019

Lecture 08: Feb. 08, 2019 4CS4-6:Theory of Computtion(Closure on Reg. Lngs., regex to NDFA, DFA to regex) Prof. K.R. Chowdhry Lecture 08: Fe. 08, 2019 : Professor of CS Disclimer: These notes hve not een sujected to the usul scrutiny

More information

Some Theory of Computation Exercises Week 1

Some Theory of Computation Exercises Week 1 Some Theory of Computtion Exercises Week 1 Section 1 Deterministic Finite Automt Question 1.3 d d d d u q 1 q 2 q 3 q 4 q 5 d u u u u Question 1.4 Prt c - {w w hs even s nd one or two s} First we sk whether

More information

Lecture 4 Recursive Algorithm Analysis. Merge Sort Solving Recurrences The Master Theorem

Lecture 4 Recursive Algorithm Analysis. Merge Sort Solving Recurrences The Master Theorem Lecture 4 Recursive Algorithm Alysis Merge Sort Solvig Recurreces The Mster Theorem Merge Sort MergeSortA, left, right) { if left < right) { mid floorleft right) / 2); MergeSortA, left, mid); MergeSortA,

More information

INFINITE SERIES. ,... having infinite number of terms is called infinite sequence and its indicated sum, i.e., a 1

INFINITE SERIES. ,... having infinite number of terms is called infinite sequence and its indicated sum, i.e., a 1 Appedix A.. Itroductio As discussed i the Chpter 9 o Sequeces d Series, sequece,,...,,... hvig ifiite umber of terms is clled ifiite sequece d its idicted sum, i.e., + + +... + +... is clled ifite series

More information

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University CS415 Compilers Lexicl Anlysis nd These slides re sed on slides copyrighted y Keith Cooper, Ken Kennedy & Lind Torczon t Rice University First Progrmming Project Instruction Scheduling Project hs een posted

More information

Midterm 1 Practice. CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

Midterm 1 Practice. CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/ Midterm 1 Prctice CS 350 Fll 2018 gilry.org/clsses/fll2018/cs350/ 1 Midterm #1: Thursdy, Septemer 27! Bring less stuff, if possile. Keep ny gs under the tle. You my hve out: pencil, pen, nd/or erser. My

More information

Riemann Integral and Bounded function. Ng Tze Beng

Riemann Integral and Bounded function. Ng Tze Beng Riem Itegrl d Bouded fuctio. Ng Tze Beg I geerlistio of re uder grph of fuctio, it is ormlly ssumed tht the fuctio uder cosidertio e ouded. For ouded fuctio, the rge of the fuctio is ouded d hece y suset

More information

,... are the terms of the sequence. If the domain consists of the first n positive integers only, the sequence is a finite sequence.

,... are the terms of the sequence. If the domain consists of the first n positive integers only, the sequence is a finite sequence. Chpter 9 & 0 FITZGERALD MAT 50/5 SECTION 9. Sequece Defiitio A ifiite sequece is fuctio whose domi is the set of positive itegers. The fuctio vlues,,, 4,...,,... re the terms of the sequece. If the domi

More information