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

  Create world database using mysql

create World database using MySQL and write a Java or C# or program to access the DB

  Write a function to insert a node after the head

In a doubly-lined list, each node points to both the next and previous nodes. The info in the each node is an integer and two pointers, one to the previous node and one to the next node - Define the node

  Creating an object oriented data model

Create an object oriented data model, including all appropriate notations, to represent the given situation. In a particular region there are a number of gardens.

  Contents of registers for independent memory-reference

Find out the contents of registers PC, AR, DR, AC, and IR for two independent memory-reference instructions below. Each instruction starts with given Initial values.

  Describe why algorithm runs in linear time-adjacency matrix

Rreached from every other vertex. Describe why your algorithm runs in linear time (O(V2) on an adjacency matrix; O(E+V) on an adjacency list).

  Replace the letter n with the letter g and alter the pointer

Then how do I replace the letter N with the letter G and alter the pointers so that the new letter appears in the list in its proper place in alphabetical order?

  What are some likely future uses and enhancements

Describe a specific web or mobile application'spurpose. How is it used? What changes has it brought about to its users? What are some likely future uses and enhancements

  Linear-time algorithm for computing the strong component

Describe a linear-time algorithm for computing the strong component containing a given vertex v - On the basis of that algorithm, explain a simple quadratic-time algorithm for computing the strong components of a digraph.

  What is the annual compound interest rate

What is the annual compound interest rate

  One e business failure

Discuss about one e-Business failure. Describe what happened and what you would have done differently. Explain whether or not the e-Business practiced sound financial planning.

  Binary search tree adt

Write a client method that returns a count of the number of nodes in a binary search tree that contain a value less than or equal to the argument value.

  Virtualization & memory

Evaluate the efficiency and reliability of both the most common nonpreemptive dispatch algorithms and the most common preemptive dispatch algorithms used for scheduling decisions. Provide one (1) example of the best use for each dispatch algorithm..

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