Question

Devise an algorithm to generate the set of strings with the exact Hamming distance of d...

Devise an algorithm to generate the set of strings with the exact Hamming distance of d from a given string P. What is the running time of the algorithm in term of Big-O notation? (Looking for Psuedo-code, empthasis on the Big-O notation)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Algorithm:

1.get the input string and input the exact hamming distance

2.Get all substrings and store in an string array

3.run 2 loops to take two strings all a time to calculate length

4.If length is same,check number of diffferent characters in string at same positions that is hamming distance

5.Check if hamming distance calculated is equal to inputted hamming distance

6.If yes then print both sub strings

Pseudo Code-

given_string=input(string)

given_hamming_distance=input(exact hamming distance)

substrings=get_all_substring(given_string)

for i=1 to length(substring)

{

for j=i+1 to length(substring)

{

if(length(substring[i])==length(substring[j]))

{ count=0

for k1=1 to length(substring[i]) , k2=1 to length(substring[j])

{

if(substring[i][k1]==substring[j][k2])

count++;

}

if(count==exact_hamming_distance)

{

print substring[i],substring[j]

}

}

}

}

the complexity of above is O(n^3)

Add a comment
Know the answer?
Add Answer to:
Devise an algorithm to generate the set of strings with the exact Hamming distance of d...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Programming language: Java m: substring length n: input strings d: Hamming distance (mismatch) I: Number of...

    Programming language: Java m: substring length n: input strings d: Hamming distance (mismatch) I: Number of letters in Sample input string (s1, s2, s3) Strings consists of: A, C, G, and T Example outputs: Generate all possible possibilities of length m(4) using the values A, C, G, and T. EX possibilites: {A,A,A,A A,A,A,C.... G,G,G,G} and find all the possible combinations that have the same sequence with a hamming distance of 1 (only 1 difference) Given n input strings of length...

  • Using the Hamming code algorithm, what should the receiver do if it receives each of these codes?...

    Using the Hamming code algorithm, what should the receiver do if it receives each of these codes? Received code:  1 1 1 0 0 0 0 1  Answer: ______________________   Received code:  0 1 0 1 1 1 0 1  Answer: ______________________   Received code:  0 1 1 1 0 1 1 0  Answer: ______________________   Received code:  0 1 1 1 1 1 0 1  Answer: ______________________   5. Below is a set of three 11 bit codes, labeled (a), (b),...

  • Construct context-free grammars that generate the given set of strings. If the grammar has more than one variable, we wi...

    Construct context-free grammars that generate the given set of strings. If the grammar has more than one variable, we will ask to write a sentence describing what sets of strings expect each variable in the grammar to generate. For example, if the grammar was: I could say "C generates binary strings of length one, E generates (non-empty) even length binary strings, and O generates odd length binary strings." It is also fine to use a regular expression, rather than English,...

  • For each of the following, construct context-free grammars that generate the given set of strings. If...

    For each of the following, construct context-free grammars that generate the given set of strings. If your grammar has more than one variable, we will ask you to write a sentence describing what sets of strings you expect each variable in your grammar to generate. For example, if your grammar were: S → EO E → EE CC 0+ EC C+01 We would expect you to say “E generates (non-empty) even length binary strings; O generates odd length binary strings;...

  • Use sorting techniques in the language Python 3 Devise an algorithm and implement it in a program to solve the following problem, similar to one often faced by an MP3 player. For our purposes, a song...

    Use sorting techniques in the language Python 3 Devise an algorithm and implement it in a program to solve the following problem, similar to one often faced by an MP3 player. For our purposes, a song consists of the following data fields: title (a nonempty ASCII string) composer (a (possibly empty) ASCII string), running time (a positive integer). Input consists of n songs and an integer k with 1 Sksn. Your program must find the k songs with longest running...

  • For each problems segment given below, do the following: Create an algorithm to solve the problem...

    For each problems segment given below, do the following: Create an algorithm to solve the problem Identify the factors that would influence the running time, and which can be known before the algorithm or code is executed. Assign names (such as n) to each factor. Identify the operations that must be counted. You need not count every statement separately. If a group of statements always executes together, treat the group as a single unit. If a method is called, and...

  • Construct context-free grammars that generate the given set of strings. If the grammar has more than one variable, we wi...

    Construct context-free grammars that generate the given set of strings. If the grammar has more than one variable, we will ask to write a sentence describing what sets of strings expect each variable in the grammar to generate. For example, if the grammar was: I could say "C generates binary strings of length one, E generates (non-empty) even length binary strings, and O generates odd length binary strings." It is also fine to use a regular expression, rather than English,...

  • (a) Design an algorithm that reveals some secret integer number from the set {1, 2, ......

    (a) Design an algorithm that reveals some secret integer number from the set {1, 2, ... , n} by guessing random numbers within the given range until the secret number has been guessed. Numbers should be replaced after being guessed such that ​it is possible to guess 2 and then 2 again​, assuming 2 is in the given range. The algorithm should return both the secret number as well as the number of guesses taken. (b) If possible, calculate the...

  • Exercise 1 Use Top-Down Design to “design” a set of instructions to write an algorithm for...

    Exercise 1 Use Top-Down Design to “design” a set of instructions to write an algorithm for “travel arrangement”. For example, at a high level of abstraction, the algorithm for “travel arrangement” is: book a hotel buy a plane ticket rent a car Using the principle of stepwise refinement, write more detailed pseudocode for each of these three steps at a lower level of abstraction. Exercise 2 Asymptotic Complexity (3 pts) Determine the Big-O notation for the following growth functions: 1....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT