recursion help appreciated During the first expedition to Mars, linguists discov
ID: 3814209 • Letter: R
Question
recursion help appreciated
Explanation / Answer
2Q Ans)Given that,
Vowels = {a,e,i,o,u}
Consonants = {b, c, d, f, g, h, j, k, l, m, n, p, q, r, s, t, v, w, x, y, z}
The conditions of forming noun are as follows
a. All nouns must begin with consonant, followed by one or more vowel- consonant pair.
b. No vowel or consonant can appear more than once in a noun.
Thus the possible nouns will be in the below forms.
1. CP1 = 21*(5*20) (Possible combinations) =2100
2. CP1P2 = 21*(5*20)*(4*19) =159600
3. CP1P2P3 = 21*(5*20)*(4*19)*(3*18) =8618400
4. CP1P2P3P4 = 21*(5*20)*(4*19)*(3*18)*(2*17) =293025600
5. CP1P2P3P4P5 = 21*(5*20)*(4*19)*(3*18)*(2*17)*(1*16)=4688409600
Where C = one of the symbol from consonants set
Pi = ith vowel – consonant pair.
Therefore total nouns following the above two conditions = 2100 + 159600 + 8618400 + 293025600 + 4688409600 = 4990215300
But Given that, the nouns { x, vuv, grok, diyik, zezelah} are not nouns.
Actually these words x, vuv, grok, diyik, zezelah are not following the above mentioned conditions.
So the total number of possible nouns are 4990215300.
------------------------------------------------------------------------------------------------------------------------------------------
3. Ans) Given that, there are c number of consonants,
v number of vowels.
Let F(c,v) be a function representing number of nouns possible with c consonants, and v vowels
Thus by observing the above question’s answer.
The number of possible nouns possible = F(c,v) = c * (v*[c-1]) * G(v-1,c-2)
Where G(a,b) = 1+ (a*b) * G(a-1,b-1) when a!=1 and b!=1
= 1 + (a*b) when a=1 or b = 1.
Here G(a,b) is a recursive function.
This function is actually adding the combination’s of new vowel – consonant pairs recursively.
For example, Let C = 21 and V = 5
Thus F( 21, 5) = 21 * (5*20) * G(4,19)
= 21*(5*20) * (1 + (4*19)*G(3,18))
= 21*(5*20)*(1+(4*19)(1+3*18*G(2,17)))
= 21*(5*20)*(1+(4*19)(1+3*18*(1+2*17*G(1,16))))
= 21*(5*20)*(1+(4*19)(1+3*18*(1+2*17*(1+1*16))))
= 21*(5*20)*(1+(4*19)(1+3*18*(1+2*17*17)))
= 21*(5*20)*(1+(4*19)(1+3*18*579))
= 21*(5*20)*(1+76*31267)
= 21*(5*20)*(2376293)
=4990215300
Hence Prooved.
Thus the below function F(c,v) is the required function.
F(c,v) = c * (v*[c-1]) * G(v-1,c-2)
Where G(a,b) = 1+ (a*b) * G(a-1,b-1) when a!=1 and b!=1
= 1 + (a*b) when a=1 or b = 1.
This function can also be written as c*(v*(c-1)) * {1+(v-1)*(c-2)*{1+(v-2)*(c-3){....... //not recommended by me... :)
If you got any doubt, Feel free to comment on it.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.