Question

In: Computer Science

Discrete Math An AZ is a string of English letters with the property that every ‘a’...

Discrete Math

An AZ is a string of English letters with the property that every ‘a’ in the string precedes every ‘z’ in the string.

For example, each of these strings is an AZ:

bedazzled

organize

paparazzo

zipper (we don’t promise a appears)

cassette (we don’t promise z appears)

monkey (we don’t promise any a or z appears at all)

None of these strings is an AZ:

za

razzmatazz

arizona

lizard

Find a recurrence and appropriate initial conditions for the number of AZzes of length n, n ≥ 0.

Give a brief justification why your recurrence is correct. (I’m not looking for a proof, but you do need to explain yourself.) For your initial conditions, use as many as you need, but no more.

Solutions

Expert Solution

Assuming that strings are made out of 26 Lower case latin alphabets. Any possible AZ string can be one of the 4 types from the following :-

1. String with 0 'a' and 0 'z' Eg : - weryufg

2. String with atleast 1 'a' and 0 'z' Eg :- khabgaaxy

3. String with atleast 1 'z' and 0 'a' Eg :- pxyzktzzce

4. String with atleast 1 'a' followed by atleast 1 'z' Eg : - xyakbaayzzztopzi

Hence , to find number of AZes of length n , we need to find the sum of the number of strings of Type1, Type2 , Type3 and Type 4.

Let the number of strings of Type i of length be N be denoted by SN[i] . Following Base case can be derieved.

Base Case : -

N = 1

S1[1] = 24 (all letters except 'a' and 'z')

S1[2] = 1 (Since length is 1 and we need atleast one 'a'. Hence only 'a')

S1[3] = 1 (Since length is 1 and we need atleast one 'z'. Hence only 'z')

S1[4] = 0 (Since length is 1 and we need atleast one 'a' and atleast 1 'z'. Hence it is impossible)

Recurrence Relation

N > 1

1. N letters except 'a' and 'z' means N-1 letters except 'a' and 'z' and 24 remaining choices for the Nth position

Hence , SN[1] = 24 * SN-1[1]

2. N letters with atleast 1 'a' and 0 'z' means N-1 letters with atleast 1 'a' and 0 'z' and there are 25 valid letters (all letters except 'z' ) for the Nth position.

N letters with atleast 1 'a' and 0 'z' means N-1 letters with 0 'a' and 0 'z' and the Nth letter is 'a'

Hence , SN[2] = 25 * SN-1[2] + SN-1[1]

3. N letters with atleast 1 'z' and 0 'z' means N-1 letters with atleast 1 'z' and 0 'z' and there are 25 valid letters (all letters except 'z' ) for the Nth position.

N letters with atleast 1 'a' and 0 'z' means N-1 letters with 0 'a' and 0 'z' and the Nth letter is 'z'

Hence , SN[3] = 25 * SN-1[3] + SN-1[1]

4. N letters with atleast 1 'a' and atlleast 1 'z' means N-1 letters with atleast 1 'a' and 1 'z' and there are 25 valid letters (all letters except 'a' ) for the Nth position. {It is necessary to not include 'a' beause all a must preceed all z}.

N letters with atleast 1 'a' and atlleast 1 'z' also means N-1 letters with atleast 1 'a' and 0 'z' and the Nth position is filled by 'z'

Hence ,SN[4] = 25 * SN-1[4] + SN-1[2]  


Related Solutions

In the game of ScrabbleTM, the letters of the English alphabet are inscribed on tiles
In the game of ScrabbleTM, the letters of the English alphabet are inscribed on tiles and a prescribed number of tiles are provided for each letter. Consider an ensemble of ScrabbleTM tiles with a probability distribution defined by the frequency of tiles in the box. Explain how to calculate the information entropy of this ensemble. It is not necessary to actually Compute the entropy, but you can if you wish.    
Suppose that a “word” is any string of six letters. Repeated letters are allowed. For our...
Suppose that a “word” is any string of six letters. Repeated letters are allowed. For our purposes, vowels are the letters a, e, i, o, and u. a) How many words are there? b) How many words begin with a vowel? c) How many words begin with a vowel and end with a vowel? d) How many words have no vowels? e) How many words have exactly one vowel? A professor teaching a Discrete Math course gives a multiple choice...
Analysis of a certain text in English gave the following table of frequencies for the letters....
Analysis of a certain text in English gave the following table of frequencies for the letters. Spacebar and all punctuation marks are ignored. Find expected number of letters A in a random excerpt of this text with 1000 letters. Find the most frequent letter and its expected number of occurrences in the same excerpt. Find the most rare letter and its expected number of occurrences in the same excerpt. Letter Count A 14810 B 2715 C 4943 D 7874 E...
Discrete Math. An old folktale says that in a faraway monastery there is a platform with...
Discrete Math. An old folktale says that in a faraway monastery there is a platform with three large posts on it and when the world began there were 64 golden disks stacked on one of the posts. The disks are all of different sizes arranged in order from largest at the bottom to smallest at the top. The disks are being moved from the original post to another according to the following rules: 1. One disk at a time is...
[Discrete math] Show that it is possible to arrange the numbers 1, 2, . . ....
[Discrete math] Show that it is possible to arrange the numbers 1, 2, . . . , n in a row so that the average of any two of these numbers never appears between them. [Hint: Show that it suffices to prove this fact when n is a power of 2. Then use mathematical induction to prove the result when n is a power of 2.] I saw the solution but I don't understand why permutation pi is using here.....
Discrete Math: Give examples of relations on the set of humans that are: a) asymmetric and...
Discrete Math: Give examples of relations on the set of humans that are: a) asymmetric and transitive b) symmetric and antisymmetric c) reflexive and irreflexive.
In the C programming language, implement the translation from regular English to Euroglish. If the letters...
In the C programming language, implement the translation from regular English to Euroglish. If the letters were uppercase, keep them uppercase in the replacement. 1. Remove one“e”from the end of words that are more than three characters long, if they happen to end in “e”. 2. Change all double letters to a single letter (including double spaces). Do not remove double line spacing (i.e. “\n”). 3. When a word ends in “ed”, change that to just “d”. Text: The cat...
DISCRETE MATH 1.Prove that the set of all integers that are not multiples of three is...
DISCRETE MATH 1.Prove that the set of all integers that are not multiples of three is countable.
Discrete Math. Problem 1. Consider the statement: “If an animal is an rhinoceros, then it has...
Discrete Math. Problem 1. Consider the statement: “If an animal is an rhinoceros, then it has a horn.” (a) Write down the CONVERSE of this statement. (b) Write down the CONTRAPOSITIVE of this statement Problem 2. Let x be a positive real number. Using the definition of rational number, write a proof by contraposition of the following: If x is irrational, then √ x + 6 is also irrational. Problem 3 Let n be an integer. Using the definition of...
A college offers teaching in Math, English, Chemistry, and Biology. The number of students enrolled in...
A college offers teaching in Math, English, Chemistry, and Biology. The number of students enrolled in each subject is listed below. If the college can only afford to hire 19 teachers, determine how many teachers should be assigned to each subject using Jefferson's method. (a) Subject Students Enrolled Teacher to Assign Math 370 English 265 Chemistry 105 Biology 80 (b) What modified divisor did you use?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT