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

  Write a xml schema for the validation of the document notes.

write a XML schema for the validation of the document notes.xml. Write the schema according to the following three approaches;1.- Based on the document structure2.- Structured (bottom-up design)3.- Type-based (top-down design)

  Multiple choice - high school excel 2003

Cell E23 has a date value and you want to place that date on an invoice prefaced with the text located in B15. Determine the command to do that?

  Determine how the representation of internal data

Imagine you are asked to write a program to print out a yearly calendar. In this program, the user enters the year desired, and the output is a calendar for that year. Determine how the representation of internal data will affect the way in which ..

  Decrypting the ciphertext to recover the plaintext

If you get ciphertext message YPHDCRPBEQTAA, decrypt to recover plaintext.

  Create a java program to arithmetic expression

Create a Java program that takes as input an infix arithmetic expression then transforms to a postfix expression and based on binary tree, it evaluates that expression.

  Let sbe the set of all people in the world for a b epsilon

let sbe the set of all people in the world. for a b epsilon s define a binary relation r as follows a b epsilon r if

  Students will create code to implement a hash algorithm and

students will create code to implement a hash algorithm and solution by addressing the followingcreate a flowchart to

  Find the first occurrence, the last occurrence

If numbers in a list aren't unique and therefore the largest number could occur more than once would the algorithm find the first occurrence, the last occurance? Every occurance?

  The binary search algorithm

- The "origin" of the Cartsian plane in math is the point where x and y are both zero. Declare a variable of type POINT named origin and set its data dields consistent with the mathematical notion of "origin".

  For no-edge weights in the graph

And all you can find (out of the still-eligible distances) is an infinity for the minimum. So... "emergency exit" case out of the while loop (which isn''t in the pseudocode algorithm).

  Describe an algorithm for sorting

The integers are NOT sorted and you CANNOT sort them. You need to see if the numbers would match the pattern if you were to sort them.

  Identify the closed loop system

Identify the closed loop system used in controlling an Industrial process and describe the method of operation of the control loop components.

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