Download String Matching - Computer Engineering - Lecture Slides and more Slides Computer Science in PDF only on Docsity! String Matching Ten Puzzling Problems in Computer Engineering Docsity.com Word Search Puzzles Type 1, With Word List Supplied AGITATOR ASSEMBLY CLUTCH CONNECTORS CONTROL COUPLING GLIDE LINT SCREEN PULLEY SEAL SWITCH VALVE AMY STEEL KEVIN BLAIR RON PALILLO BARBARA BINGHAM KIRSTEN BAKER SHAVAR ROSS BRUCE MAHLER LARRY ZERNER STU CHARNO CAROL LACATELL MARK NELSON SUSAN BLU DANA KIMMELL PAUL KRATKA TONY GOLDWYN JOHN FUREY RICHARD YOUNG TRACIE SAVAGE The puzzle below is a little harder than the normal word search: one of the 36 first/last names has been left out (which one?) Docsity.com A Challenging Hybrid Word Search Puzzle
ESAHCGTS IHDREHTO
YIEMULEROWGRPENA
VNHAEBDATORLEE FN
AERSLANEAHAAEAGI
RDNIUILNGSNTRTRMM
GZNAASESKDGOEHP EE
CGLRRNIARTRELRDA
RMDAJYCSAYBDAIS O'S
AONIONCCDORDOASO
PEPOCHHCRREMABSA
SHCAEPMIEODAIRTH
KDIMITOWNNWINOSC
“House, M_D"s Robert Japanese food Sawdust quiets “Walk the
“lt makes its own " - to an end” Infintesimals Doles
Dice game Whooping, bird Deadly sin Drunks
Basketball position Rapper Gold Deadhy sin Ethan Rayne
Google “The” Water gocs down Deadby sin Japanese toons
Unit of time & space Wacky witches Deadly sin Peter Gabriel's “Cuntains”
Fucew fruit “White and . “Runaway , 1 This 2.Thai 3.
Shy The Fifth Element Two-by-four ‘The Malian Job's Seth
® Docsity.com
Word Search Puzzle with a Twist This “Missing Peace Puzzle” was used in a qualifying round of World Puzzle Championships. Supply the 16 missing letters at the center of the grid so that the word-search puzzle contains 18 of the 19 names of Nobel Peace Prize winners listed. Docsity.com String Matching: Problem Definition Given a data string with n symbols and a pattern string with m symbols: 1. Does the pattern string appear in the data string? 2. What are the locations of all occurrences of the pattern in the data? LEAGLEUROKRDPOXWYARDRXEOIEOTHYROIDTLHNSNTETPBNEL AJCOZSLMOIMAWZOHCJNMIUNRKFJERSEYELNBVEGRETXZJTED 00 12 24 36 48 60 72 84 Data string of length n = 96 symbols Pattern string of length m = 5 symbols: EAGLE EAGLE The brute-force, or sliding window, algorithm Consider all possible positions where the pattern might begin (n – m + 1) For each start position, do up to m comparison to see if there is a match EAGLE Worst-case complexity = O(mn); e.g., pattern “aaaaa”, data “aaaaaaaaaa” EAGLE Docsity.com Needle in a Haystack: Internet Search Search for the 10-symbol string “ h e l e n h u n t ” 2.1M hits 3 years ago 5.4+M hits in mid 2012 Docsity.com Needle in a Haystack: Doing Less Work For a particular pattern and unpredictable data strings, preprocess the pattern so that searching for it in various data strings becomes faster For a particular data string and unpredictable patterns, preprocess the data string so that when a pattern is supplied, we can readily find it with much less work Analogy: Magnetize the needle Analogy: Do a thorough search of the haystack for different types of needles and place markers to guide future searches Docsity.com Example of Preprocessing the Pattern String Devise an efficient method for finding the pattern “abcbab” in various data strings formed from the symbols a, b and c a c a a c 0 1 a 2 b 3 c b 4 5 a 6 b b,c a c a c b Data string: a b c b b b a b c b a b b c a a b c b a b c b a b c b b 0 1 2 3 4 0 0 1 2 3 4 5 6 0 0 1 1 2 3 4 b,c b 5 6 3 4 5 6 3 4 0 O(n) instead of O(mn) Docsity.com