Week 10: test contains all material from Week 1 - PowerPoint PPT Presentation

1 / 37
About This Presentation
Title:

Week 10: test contains all material from Week 1

Description:

There is a starting and final state in the automaton. ... (n2), where n is the size of the automaton since d(s, i) could contain O(n) states. ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 38
Provided by: depts180
Category:

less

Transcript and Presenter's Notes

Title: Week 10: test contains all material from Week 1


1
.
  • Week 10 test contains all material from Week 1
    Week 8, not including this week

2
Week 9 String Matching Allowing Errors
  • Problem Given a short pattern P of length m, a
    long text T of length n, and a maximum allowed
    number of errors k, find all the text positions
    where the pattern occurs with at most k errors.

3
Dynamic Programming
  • Ci,j be the number of errors allowed.
  • Three kinds of error mismatch (a, b), insertion(
    a, )and deletion ( , a).

4
The matrix
  • The dynamic programming algorithm search
    survey in the text surgery with two errors.
    Bold entries indicate matching positions. Running
    time O(n?m).

s u r g e r y
0 0 0 0 0 0 0 0
s 1 0 1 1 1 1 1 1
u 2 1 0 1 2 2 2 2
r 3 2 1 0 1 2 2 3
v 4 3 2 1 1 2 3 3
e 5 4 3 2 2 1 2 3
y 6 5 4 3 3 2 2 2
5
String Matching Allowing Errors
  • O(n?k) algorithm, where n is the length of the
    pattern and k the number of errors allowed.
  • Ci,q the number of errors for ci,iq,
  • q-k, -(k1), ,0, 1, 2, , k.
  • Ci,iq Ci-1, iq-1 if pitiq.
  • else CI,iq1minCi-1,iq, CI, iq-1,
    Ci-1,iq-1.

6
  • An NFA for approximate string matching of
    the pattern survey with two errors. The shaded
    states are those active after reading the text
    surgery. Unlabelled transitions match any
    character.(Also O(nk) time.)

7
Regular expressions Matching
  • Regular expression
  • Any letter x in ???,is a regular expression,
    where ? is the set of all letters.
  • if A and B are regular expression, then AB,
    A.B and (A) are regular expressions.

8
Regular expressions Matching
  • Given an regular expression E and a string T,
    find all the substrings in T that match E.
  • Let d(i) be the set of all states in the
    automaton that can be reached after T1T2Ti is
    accepted.
  • Given d(i), d(i1) can be computed easily.
  • There is a starting and final state in the
    automaton.
  • Whenever the final state is reach, we find a
    substring in T that match the expression.

9
(No Transcript)
10
(No Transcript)
11
(No Transcript)
12
(No Transcript)
13
Example
  • E(AAA).(BAB).
  • TABBAAAB.
  • D(1)a,b,d,c, e, f, g, i
  • D(2)a,b,d, h,l ,
  • D(3)a,b,d.
  • D(4)a,b,d,c,e,f,g,i
  • D(5)a,b,d,c,e,f,g, i,j
  • D(6)a,b,d,c,e,f,g,i,j
  • D(7)a, h, k,l.

14
Running time
  • O(n2), where n is the size of the automaton since
    d(s, i) could contain O(n) states.

15
Choices of Search Engines
  • Many search engines exist to compete for users
  • The results are not necessarily the same
  • Different users prefer different search engines
  • Search results may, in the future, be biased
    towards paid advertisements.

16
GOOGLE City University
  1. City University London - the University for
    business and the ... ... The University for
    business and the professions. Contact Us About
    City University Maps Directions, AZ Index
    Site Map Help. Prospective Students. ...
    Description Official site with information
    about courses, research, schools, and
    departments. Includes details...
  2. City University HomeA University which believes
    in forward-thinking business and leadership
    skills, exposing students to the latest
    technology in all courses of study. Description
    A private, nonprofit institution founded to serve
    working adults wanting to pursue educational
    opportunit...
  3. Welcome to Dublin City University... here...
    Dublin City University, Dublin 9, Ireland. Tel.
    353 (0) 1700 5000, Fax. 353 (0) 1 836 0830.
    Page updated 02/09/03 legal. ... Description
    Information on facilities, services, degree
    courses, research, the campus, student life, the
    library...
  4. The City University of New YorkDescription The
    University's Main Website.
  5. City University of Hong KongAD Working Group
    lends staff, students an ear. Several issues
    stillevoked strong emotions as staff members and
    students voiced their ... Description Formerly
    the City Polytechnic of Hong Kong. Includes
    information on university, links to learning...
  6. Welcome to Oklahoma City University... At
    Oklahoma City University, our students come
    first. Our ... Oklahoma CityUniversity offers a
    quality, values-centered education. United ...
    Description Admissions, academic programs and
    alumni relations, sports, services, news,
    calendar of events and...

17
YAHOO
  1. City University London - the University for
    business and the ... ... The University for
    business and the professions. Contact Us About
    City University Maps Directions, AZ Index
    Site Map Help. Prospective Students. ...
  2. City University A University which believes in
    forward-thinking business and leadership skills,
    exposing students to the latest technology in all
    courses of study.www.cityu.edu/ - 3k - Cached -
    More pages from this site
  3. Dublin City University ... here... Dublin City
    University, Dublin 9, Ireland. Tel. 353 (0) 1
    700 5000, Fax. 353 (0) 1 836 0830. Page updated
    02/09/03 legal. ...www.dcu.ie/ - 6k - Cached -
    More pages from this site
  4. City University of New York The University's
    Main Website.www.cuny.edu/ - More pages from
    this site
  5. City University of Hong Kong AD Working Group
    lends staff, students an ear. Several issues
    still evoked strong emotions as staff members and
    students voiced their ...www.cityu.edu.hk/ - 26k
    - Cached - More pages from this site
  6. Oklahoma City University ... At Oklahoma City
    University, our students come first. Our ...
    Oklahoma City University offers a quality,
    values-centered education. United
    ...www.okcu.edu/ - 20k - Cached - More pages
    from this site

18
AllTheWeb
  1. Apartment Listings in University
    City  (sponsored)St. Louis, Missouri area
    apartment listings at Apartments.com. Free
    nationwide apartment search with visual rental
    listings online.http//www.apartments.com
  2. City University - Washington  (sponsored)Contact
    information and resources such as yellow page
    information, phone number, address, maps and
    directions as provided by QwestDex.http//service
    .bfast.com
  3. City University Apartments - Rent.com  (sponsored)
    Rent.com has millions of free apartment listings
    nationwide. Get 100 when you sign a lease near
    your school - it's easy.http//www.rent.com
  4. City University London - the University for
    business and the professions... Contact Us
    About City University Maps Directions A-Z
    Index Site Map Help ... Description
    Official site with information about courses,
    research, schools, and departments. Includes
    details of news and events.more hits from 
    http//www.city.ac.uk/  -  13 KB
  5. Flash UpgradeDescription A University which
    believes in forward-thinking business and
    leadership skills, exposing students to the
    latest technology in all courses of
    study.http//www.cityu.edu/  -  27 KB
  6. Welcome to Dublin City University...
    KnowledgeWorks, wins DCU Mallin-invent award Full
    text you can go anywhere in the world from
    here... Dublin City University, Dublin 9,
    Ireland. Tel. 353 (0) 1 700 5000, Fax. 353 (0)
    1 836 0830. Page updated 02/09/03 legal search
    ... Description Information on facilities,
    services, degree courses, research, the campus,
    student life, the library and DCU news.

19
MSN Search
  1. City University of New York Details the CUNY
    system's campuses and admissions requirements.
    Eye photos of notable graduates such as actor
    Judd Hirsch.www.cuny.edu
  2. City University Offers prospectus, admissions,
    academic calendar, courses and degrees, and
    news.www.cityuniversity.net
  3. City University Private, nonprofit institution
    located in Belleview, Washington, offers higher
    education opportunities to working professionals
    and lifelong learners.www.cityu.edu
  4. Valley City University Admissions Site covers
    financial aid and tuition and offers a virtual
    campus tour. Site also provides access to an
    online application.www.vcsu.nodak.edu/admissions
  5. Oklahoma City University The Oklahoma City
    University site contains information about
    admissions, academic departments and student
    life. The site also provides library resources,
    faculty information and news.frodo.okcu.edu
  6. Dublin City University, Dublin - TripAdvisor
    Browse reviews of the Dublin City University in
    Dublin, County Dublin, Ireland. Check consumer
    reviews, articles and opinions about the Dublin
    City University.www.tripadvisor.com/Hotel_Review-
    g186605-d209093-Reviews-Dublin_City_U...

20
AOL Search
  1. City University London - the University for
    business and the ... - ... The University for
    business and the professions. Contact Us About
    City University Maps Directions, AZ Index
    Site Map Help. Prospective Students. ...
    http//www.city.ac.uk/
  2. City University Home - A University which
    believes in forward-thinking business and
    leadership skills, exposing students to the
    latest technology in all courses of study.
    http//www.cityu.edu/
  3. Welcome to Dublin City University - ... here...
    Dublin City University, Dublin 9, Ireland. Tel.
    353 (0) 1 700 5000, Fax. 353 (0) 1 836 0830.
    Page updated 02/09/03 legal. ...
    http//www.dcu.ie/
  4. http//www.cuny.edu/ - The University's Main
    Website.http//www.cuny.edu/
  5. City University of Hong Kong - AD Working Group
    lends staff, students an ear. Several issues
    still evoked strong emotions as staff members and
    students voiced their ... http//www.cityu.edu.hk
    /
  6. Welcome to Oklahoma City University - ... At
    Oklahoma City University, our students come
    first. Our ... Oklahoma City University offers a
    quality, values-centered education. United ...
    http//www.okcu.edu/

21
Ask Jeeves
  1. City University of Hong Kong Formerly the City
    Polytechnic of Hong Kong. Includes information on
    university, links to learning resources, research
    and departmental information.....Fromwww.cityu.ed
    u.hk/
  2. City University Text Version. The University for
    business and the professions ... Contact Us
    About City University Maps Directions A-Z
    Index Site Map Help...Fromwww.city.ac.uk/
  3. New Jersey City University Official site includes
    graduate and undergraduate information, news,
    events, online learning, calendars, and
    athletics.Fromwww.njcu.edu/
  4. Elizabeth City State University Admission
    Application Introduction 2004-2005 APPLICATION
    FOR ADMISSION. Welcome to the Elizabeth City
    State University Online Application. New
    Freshmen...Fromwww.ncmentor.org/applications/unc/
    apply/elizabeth_city_state_univ...
  5. City University A University which believes in
    forward-thinking business and leadership skills,
    exposing students to the latest technology in all
    courses of study.Fromwww.cityu.edu/
  6. The City College of New York City College of New
    York (CUNY) A senior college of The City
    University of New York. Located in Manhattan.
    138th Street at Convent Avenue. A Harlem
    masterpiece in the neo-Gothic...Fromwww.ccny.cuny
    .edu/

22
HotBot
  • 1. City University of New YorkDetails the CUNY
    system's campuses and admissions requirements.
    Eye photos of notable graduates such as actor
    Judd Hirsch.www.cuny.edu/ - August 10, 2003 - 25
    KB
  • 2. City UniversityPrivate, nonprofit institution
    located in Belleview, Washington, offers higher
    education opportunities to working professionals
    and lifelong learners.www.cityu.edu/ - August
    23, 2003 - 27 KB
  • 3. New Jersey City UniversityExplore the course
    requirements for this liberal arts institution.
    Link to admissions and financial aid information.
    ... New Jersey City University. 2039 Kennedy
    Boulevard Jersey City, New Jersey 07305-1597 ...
    www.njcu.edu/ - November 1, 2003 - 20 KB
  • 4. City University London - the University for
    business and the...... Contact Us About City
    University Maps Directions. A-Z Index Site
    Map Help ... www.city.ac.uk/ - September 28,
    2003 - 14 KB
  • 5. Oklahoma City UniversityTake a tour of the
    campus, and explore a roster of academic
    programs. ... At Oklahoma City University, our
    students come first. ... www.okcu.edu/ - October
    26, 2003 - 20 KB
  • 6. University of Missouri, Kansas CityUniversity
    based in Kansas City, Missouri, presents and
    overview of its academic programs, and offers
    campus news. ... UNIVERSITY OF MISSOURI-KANSAS
    CITY. Bulletin. Winter 2004 Fee Update, more...
    ... www.umkc.edu/ - October 23, 2003 - 16 KB

23
Lycos
  • 1. City University London - the University for
    business and the... Contact Us About City
    University Maps Directions A-Z Index Site
    Map Help More results from www.city.ac.uk  
    September 16, 2003 - 14 KB
  • 2. Flash UpgradeA University which believes in
    forward-thinking business and leadership skills,
    exposing students to the latest technology in all
    courses of study.www.cityu.edu   November 1,
    2003 - 27 KB
  • 3. The City University of New YorkThe
    University's Main Website.www.cuny.edu  
    December 31, 1969 - 121 B
  • 4. Welcome to Dublin City University
    KnowledgeWorks, wins DCU Mallin-invent award Full
    text you can go anywhere in the world from
    here... Dublin City University , Dublin 9,
    Ireland. Tel. 353 (0) 1 700 5000, Fax. 353 (0)
    1 836...More results from www.dcu.ie   October
    29, 2003 - 5 KB
  • 5. City University of Hong KongFormerly the City
    Polytechnic of Hong Kong. Includes information on
    university, links to learning resources, research
    and departmental information and student
    information.More results from www.cityu.edu.hk
      October 29, 2003 - 26 KB
  • 6. HCU HomePage -English- contact us For any
    suggestion and requests to this web site,
    www-admin_at_hiroshima-cu.ac.jp Feel free to link
    this web site. Hiroshima City University More
    results from www.hiroshima-cu.ac.jp   May 11,
    2003 - 26 KB

24
Teoma
  1. City University of Hong Kong Formerly the City
    Polytechnic of Hong Kong. Includes information on
    university, links to learning resources, research
    and departmental information...www.cityu.edu.hk/
    Related PagesMore Results from
    www.cityu.edu.hk
  2. City University Text Version. The University for
    business and the professions ... Contact Us
    About City University Maps Directions A-Z
    Index Site Map Help...www.city.ac.uk/More
    Results from www.city.ac.uk
  3. New Jersey City University Official site includes
    graduate and undergraduate information, news,
    events, online learning, calendars, and
    athletics.www.njcu.edu/Related PagesMore
    Results from www.njcu.edu
  4. Elizabeth City State University Admission
    Application Introduction 2004-2005 APPLICATION
    FOR ADMISSION. Welcome to the Elizabeth City
    State University Online Application. New
    Freshmen...www.ncmentor.org/applications/unc/apply
    /el...
  5. City University A University which believes in
    forward-thinking business and leadership skills,
    exposing students to the latest technology in all
    courses of study.www.cityu.edu/
  6. The City College of New York City College of New
    York (CUNY) A senior college of The City
    University of New York. Located in Manhattan.
    138th Street at Convent Avenue. A Harlem
    masterpiece in the neo-Gothic...www.ccny.cuny.edu/
    More Results from www.ccny.cuny.edu

25
MetaSearch Engine
  • Metasearch Engines are designed to increase the
    coverage of web by forwarding users queries to
    multiple search engines
  • Users requests are sent to multiple search
    engines such as AlltheWeb, Google, MSN.
  • Then the results from the individual search
    engine are combined into a single result set to
    present to users.

26
Longest common subsequence
  • Definition 1 Given a sequence Xx1x2...xm,
    another sequence Zz1z2...zk is a subsequence of
    X if there exists a strictly increasing sequence
    i1i2...ik of indices of X such that for all
    j1,2,...k, we have xijzj.
  • Example 1 If Xabcdefg, Zabdg is a subsequence
    of X. Xabcdefg,Zab d g

27
  • Definition 2 Given two sequences X and Y, a
    sequence Z is a common subsequence of X and Y if
    Z is a subsequence of both X and Y.
  • Example 2 Xabcdefg and Yaaadgfd. Zadf is a
    common subsequence of X and Y.
  • Xabc defg
  • Yaaaadgfd
  • Za d f

28
  • Definition 3 A longest common subsequence of X
    and Y is a common subsequence of X and Y with the
    longest length. (The length of a sequence is the
    number of letters in the seuqence.)
  • Longest common subsequence may not be unique.
  • Example abcd
  • acbd
  • Both acd and abd are LCS.

29
Longest common subsequence problem
  • Input Two sequences Xx1x2...xm, and
  • Yy1y2...yn.
  • Output a longest common subsequence of X and Y.
  • A brute-force approach
  • Suppose that m?n. Try all subsequence of X
    (There are 2m subsequence of X), test if such a
    subsequence is also a subsequence of Y, and
    select the one with the longest length.

30
Charactering a longest common subsequence
  • Theorem (Optimal substructure of an LCS)
  • Let Xx1x2...xm, and Yy1y2...yn be two
    sequences, and
  • Zz1z2...zk be any LCS of X and Y.
  • 1. If xmyn, then zkxmyn and Z1..k-1 is an
    LCS of X1..m-1 and Y1..n-1.
  • 2. If xm ?yn, then zk?xm implies that Z is an LCS
    of X1..m-1 and Y.
  • 2. If xm ?yn, then zk?yn implies that Z is an LCS
    of X and Y1..n-1.

31
The recursive equation
  • Let ci,j be the length of an LCS of X1...i
    and X1...j.
  • ci,j can be computed as follows
  • 0
    if i0 or j0,
  • ci,j ci-1,j-11 if
    i,jgt0 and xiyj,
  • maxci,j-1,ci-1,j if i,jgt0
    and xi?yj.
  • Computing the length of an LCS
  • There are n?m ci,js. So we can compute them in
    a specific order.

32
The algorithm to compute an LCS
  • 1. for i1 to m do
  • 2. ci,00
  • 3. for j0 to n do
  • 4. c0,j0
  • 5. for i1 to m do
  • 6. for j1 to n do
  • 7.
  • 8. if xI yj then
  • 9. ci,jci-1,j-11
  • 10 bi,j1
  • 11. else if ci-1,jgtci,j-1 then
  • 12. ci,jci-1,j
  • 13. bi,j2
  • 14. else ci,jci,j-1
  • 15. bi,j3
  • 14

33
  • Example 3 XBDCABA and YABCBDAB.

34
Constructing an LCS (back-tracking)
  • We can find an LCS using bi,js.
  • We start with bn,m and track back to some cell
    b0,i or bi,0.
  • The algorithm to construct an LCS
  • 1. im
  • 2. jn
  • 3. if i0 or j0 then exit
  • 4. if bi,j1 then
  • ii-1
  • jj-1
  • print xi
  • 5. if bi,j2 ii-1
  • 6. if bi,j3 jj-1
  • 7. Goto Step 3.
  • The time complexity O(nm).

35
Shortest common supersequence
  • Definition Let X and Y be two sequences. A
    sequence Z is a supersequence of X and Y if both
    X and Y are subsequence of Z.
  • Shortest common supersequence problem
  • Input Two sequences X and Y.
  • Output a shortest common supersequence of X and
    Y.
  • Example Xabc and Yabb. Both abbc and abcb are
    the shortest common supersequences for X and Y.

36
  • Recursive Equation
  • Let ci,j be the length of an LCS of X1...i
    and X1...j.
  • ci,j can be computed as follows
  • j
    if i0
  • i
    if j0,
  • ci,j ci-1,j-11 if
    i,jgt0 and xiyj,
  • minci,j-11,ci-1,j1 if
    i,jgt0 and xi?yj.

37
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com