Give an efficient algorithm that takes as input a pattern

Assignment Help Data Structure & Algorithms
Reference no: EM131036683

String matching based on repetition factors

Let yidenote the concatenation of string y with itself i times. For example, (ab)3= ababab. We say that a string x ∈Σ* has repetition factor r if x = yr for some string y ∈Σ* and some r > 0. Let p(x) denote the largest r such that x has repetition factor r.

a. Give an efficient algorithm that takes as input a pattern P [1..m]and computes the value ρ(Pi) for i = 1,2,...,m. What is the running time of your algorithm?

b. For any pattern P [1..m], let (P*) be defined as max1≤i≤m ρ(pi). Prove that if the pattern P is chosen randomly from the set of all binary strings of length m, then the expected value of ρ(P) is O(1).

c. Argue that the following string-matching algorithm correctly finds all occurrences of pattern P in a text T[1..n] in time O(ρ*(P) n + m):

REPETITION-MATCHER(P, T )

1 m = P. length
2 n = T. length
3 k = 1 + ρ*(P)
4 q = 0
5 s = 0
6 while s ≤ n - m
7 if T [s + q + 1] = = P [q + 1]
8 q = q + 1
9 if q = = m
10 print "Pattern occurs with shift" s
11 if q = = m or T [s + q + 1] ≠ P[q + 1]
12 s = s C max(1, [q/k])
13 q = 0

This algorithm is due to Galil and Seiferas. By extending these ideas greatly, they obtained a linear-time string-matching algorithm that uses only O(1) storage beyond what is required for P and T.

Reference no: EM131036683

Questions Cloud

Is this also true for a real-gas mixture : The sum of the mole fractions for an ideal-gas mixture is equal to 1
An isolated island in terms of the impact : The purchasing department is not an isolated island in terms of the impact it has on other departments or how other departments impact purchasing. Discuss the following:What are the roles, functions, and responsibilities of the purchasing departme..
Civilian labor force participation rate : You must find an official source, not some random blogger or newspaper editorial. Your assignment is to find: The civilian labor force participation rate for those 16 to 19 years old, in March 2016
Does this law hold exactly for ideal-gas mixtures : Does this law hold exactly for ideal-gas mixtures? How about nonidealgas mixtures?
Give an efficient algorithm that takes as input a pattern : Give an efficient algorithm that takes as input a pattern P [1..m]and computes the value ρ(Pi) for i = 1,2,...,m. What is the running time of your algorithm?
Correct change in monetary policy : Suppose that the economy is producing below potential GDP and the Fed implements the correct change in monetary policy, but not until after the economy has passed the trough of the recession. Then
Document explaining the commodity strategy : Why is it important to establish a document explaining the commodity strategy and share it with others? What are the possible consequences of not to do so?
What is your role as a health care team member : What is your role as a health care team member - how do you define professionalism and how does professional responsibility influence your work?
When are these two equivalent : What is the difference between the component pressure and the partial pressure

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd