Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8 a) The brute-force pattern matching algorithm on the slides runs until either a. A match is found, or b. All placements of the pattern

8 a) The brute-force pattern matching algorithm on the slides runs until either a. A match is found, or b. All placements of the pattern have been tried Write the pseudocode for an algorithm such that it reports all occurrences of a pattern P with the number of shifts needed to achieve that.

b) Show the comparisons the naive string matcher makes for the pattern P = 0001 in the text T = 000010001010001

c) Suppose that all characters in the pattern P are different. Show the pseudocode of an algorithm that accelerate the brute-force algorithm to run in time O(n) on an n-character text T.

d) Using Boyer-Moore's algorithm and the text "puppy puppet looks happy", find the substring puppet. Compute first the last occurrence function. For the alphabet assume it is the letters that compose the text. Discard blank spaces.

e) Following the Boyer-Moore algorithm, what is the number of comparisons required for finding the the previous pattern in the given text? Help yourself with a drawing similar to the examples showed in class and paste it with your answer.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions

Question

How does a credit card differ from a debit card? Explain.

Answered: 1 week ago