23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Re<strong>in</strong>forcement<br />

R-12.1<br />

List the prefixes of the str<strong>in</strong>gP = "aaabbaaa" that are also suffixes of P.<br />

R-12.2<br />

Draw a figure illustrat<strong>in</strong>g the comparisons done by brute-force pattern match<strong>in</strong>g<br />

for the text "aaabaadaabaaa" <strong>and</strong> pattern "aabaaa".<br />

R-12.3<br />

Repeat the previous problem for the BM pattern match<strong>in</strong>g algorithm, not<br />

count<strong>in</strong>g the comparisons made to compute the last(c) function.<br />

R-12.4<br />

Repeat the previous problem for the KMP pattern match<strong>in</strong>g algorithm, not<br />

count<strong>in</strong>g the comparisons made to compute the failure function.<br />

R-12.5<br />

Compute a table represent<strong>in</strong>g the last function used <strong>in</strong> the BM pattern match<strong>in</strong>g<br />

algorithm for the pattern str<strong>in</strong>g "the quick brown fox jumped over<br />

a lazy cat" assum<strong>in</strong>g the follow<strong>in</strong>g alphabet (which starts with the space<br />

character): σ = { ,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}.<br />

R-12.6<br />

Assum<strong>in</strong>g that the characters <strong>in</strong> alphabet σ can be enumerated <strong>and</strong> can be used<br />

to <strong>in</strong>dex arrays, give an O(m+ |σ|)-time method for construct<strong>in</strong>g the last function<br />

from an m-length pattern str<strong>in</strong>g P.<br />

R-12.7<br />

Compute a table represent<strong>in</strong>g the KMP failure function for the pattern str<strong>in</strong>g<br />

"cgtacgttcgt ac".<br />

R-12.8<br />

Draw a st<strong>and</strong>ard trie for the follow<strong>in</strong>g set of str<strong>in</strong>gs: {abab,baba,<br />

ccccc,bbaaaa, caa,bbaacc,cbcc,cbca}.<br />

R-12.9<br />

Draw a compressed trie for the set of str<strong>in</strong>gs given <strong>in</strong> Exercise R-12.8.<br />

783

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!