math220 discrete math test 3 solutions

10
Q1) because every children must have 1 balloon so Meg give 1 balloon to each child first no of balloon remains = 25-16 = 9 So no of ways to distribute 9 balloons to 16 children is ( 16 +91 91 ) = ( 24 8 ) Q2) each student have 5 choices :- he can chose from 1 to 5 no of subjects so count = ( ( 5 1 ) + ( 5 2 ) + ( 5 3 ) + ( 5 4 ) + ( 5 5 ) ) 6 =31 6 Q3) a) First i will give one candy to each one now 2 candies remain so no of way to give 2 identical candies to 4 boys is = ( 2 +41 41 ) = ( 5 3 ) = 10 b) no of ways to give 6 candies to four boys = ( 6 +41 41 ) = ( 9 3 ) =84 Q4) because each bag should contain atleast 1 certificate so after putting 1 certificate to each bag no of certificates remain =11-4=7

Upload: geniusamit

Post on 01-May-2017

220 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Math220 Discrete Math Test 3 Solutions

Q1)because every children must have 1 balloon so Meg give 1 balloon to each child firstno of balloon remains = 25-16 = 9

So no of ways to distribute 9 balloons to 16 children is (16+9−19−1 )=(248 )

Q2)each student have 5 choices :- he can chose from 1 to 5 no of subjects

so count = ((51)+(52)+(53)+(54)+(55))6

=316

Q3)

a) First i will give one candy to each one now 2 candies remain so no of way to give 2 identical

candies to 4 boys is = (2+4−14−1 ) =(53) = 10

b)

no of ways to give 6 candies to four boys = (6+4−14−1 )=(93)=84

Q4)because each bag should contain atleast 1 certificate so after putting 1 certificate to each bag no of certificates remain =11-4=7

so no of ways to put 7 certificate in 4 bags are= (7+4−14−1 )=(103 )=120

Q5)Multiplying generation function says that

by multiplying A(x) an B(x) we get

Page 2: Math220 Discrete Math Test 3 Solutions

so

(∑k=0inf

3k zk )(∑k=0inf

3k zk )=∑k=0

inf

¿¿

(∑k=0inf

3k zk )(∑k=0inf

3k zk )=∑k=0

inf

¿¿

(∑k=0inf

3k zk )(∑k=0inf

3k zk )=∑k=0

inf

( (k+1 )3k ) zk

Q6) Let x=and n= 3 we get (1+x)−n

Put value of x and n we get =>1-3*(-4z2)+3*(3+1)* (−4 z2)2/2 - 3*(3+1)*(3+2)* (−4 z2)3/6=>1+12z2+96z4+640z6

Q7)Let we denote four families by x1,x2,x3 and x4so we have to calculate x1+x2+x3+x4=36given condition are 6≤x1≤7 14≤x2≤18 6≤x3≤10 6≤x4≤10Let y1=x1-6

y2=x2-14y3=x3-6y4=x4-6

so now we have to calculate y1+y2+y3+y4=4With conditions 0≤y1≤1 0≤y2≤4 0≤y3≤4 0≤y4≤4

Let S be the set of all nonnegative integral solutions of the equation y1+y2+y3+y4 = 4.Let P1 be the property that y1>=2, P2 the property that y2>= 5, P3 the property thaty3>= 5, and P4 the property that y4>=5. Let Ai denote the subset of S consisting of thesolutions satisfying the property Pi, 1 <= i <= 4. Then the problem is to find the cardinalityA1 ∩ A2∩A 3 ∩ A4 bythe inclusion-exclusion principle. In fact,

|S|=⟨44 ⟩=(4+4−14 )=35

Page 3: Math220 Discrete Math Test 3 Solutions

|A1|=⟨42 ⟩=(4+2−12 )=10

|A2|=0|A3|=0|A 4|=0All intersection will be also zeroSo answer will be 35-10=25

Q8) 1#include<stdio.h>#include<conio.h>int sum_no(int n) { if ( n == 1 ) return 1 ; else {

return sum_no(n-1)+n ; }}void main(){int N,b ;int sum=0;printf("Enter the value of N\n ");scanf("%d" ,&N);sum=sum_no(N);printf(" Sum=%d\n" , sum);}

Q8) 2 :- no previous algorithm didn’t use tail recursion. Programme that use tail recursion is as follows

#include<stdio.h>#include<conio.h>int tailSum_noAux(int k, int ksum, int n ){ if ( k == n ) { return ksum ; } else { return tailSum_noAux(k+1, ksum+(k+1), n) ; }}

Page 4: Math220 Discrete Math Test 3 Solutions

int tailSum_no (int n){ return tailSum_noAux(1,1,n) ;}

void main(){int N,b ;int sum=0;printf("Enter the value of N\n ");scanf("%d" ,&N);sum=tailSum_no(N);printf(" Sum=%d\n" , sum);}

Q8) 3#include<stdio.h>#include<conio.h>void main(){int N,b ;int sum=0;printf("Enter the value of N\n ");scanf("%d" ,&N);b=1;while(b<=N){sum=sum+b;// sum+=bb++;}printf(" Sum=%d\n" , sum);}

Q9)

Page 5: Math220 Discrete Math Test 3 Solutions

an=(n+1)an−1by expanding an−1 an=(n+1)(n-1+1)an−2

=(n+1)(n)an−2=(n+1)(n)(n-1)an−3=(n+1)(n)(n-1)(n-2).........2a0=!(n+1) * 7

Q10)1)

T(n)=3 if n=1

T(n)=2T(n2 )+1 if n>1

2) Θ(n)

Q11)an=-2an−1+15an−2

From this we get the equationr2+2r-15=0=>(r+5)(r-3)=0So solution is

an=α 13n+α 2(−5)

n

Now put value of a0 and a1in this equation we get 2=α 1+α 2 ....................................(1)

-2=3α 1-5α 2 .....................................(2)

by solving (1) and (2) we get α 1=1 and α 2=1

so solution of recurrence relation is an=3n+(−5)n

Page 6: Math220 Discrete Math Test 3 Solutions

Q12)1)

2)both strategies have same time complexity but choosing largest element first cut many branches of tree with the help of condition (if t<s return) . so largest element first is slighter better choice.

Q)13 an=-3an−1-3an−2-an−3

From this we get the equationr2+3 r2+3r+1=0=>(r+1)3=0So solution is

an=α 1(−1)n+(n+1)α2(−1)

n+(n+1)(n+2)

2α2(−1)

n

Now put value of a0 , a1 and a2in this equation we get -4=α 1+α 2+α 3 ....................................(1)

-4=−α 1-2α 2-3α 3 ....................................(2)0=α 1+3α 2+6α 3....................................(3)by solving (1), (2) and (2) we get α 1=-21 and α 2=27 and α 3=-10

Page 7: Math220 Discrete Math Test 3 Solutions

so solution of recurrence relation is

an=−21∗(−1)n+(n+1 )∗27∗(−1)n+(n+1)(n+2)

2∗(−10 )∗(−1)n

Q14)S(n,k) the Stirling number of the 2nd kindgiven n= 9 distinguishable books and k= 4 identical displaysso answer is S(9,4)

S(n,k)= 1!4 [(−1)4(40)09+(−1)3(41)19+(−1)2(42 )29+(−1)1(43)39+(−1)0(44)49]

=7770

Q15)1)

With the help of masters theorem we get a=2 , b=4 so n logba=nlog42=n0=1 so complexity is Θ(log 4n)

2)With the help of masters theorem we get a=1 , b=5 so n logba=nlog51=n0=1 so complexity is Θ(√n)

Q16)

an=-2an−1+15an−2given a0=2 , a1=-2 and c0=-2 , c1=15

letµz be the generating function for ∐n=0

inf

µz=p1(z )q2(z)

Where p1(z) = a0+(a1-a0c0)Z =2+2Z

S(n,k)=

Page 8: Math220 Discrete Math Test 3 Solutions

And q2(z) = 1-c0Z-c1Z2

=1+2Z-15Z2

=(1+5Z)(1-3Z)so

µz=2+2Z

(1+5Z )(1−3 Z)

µz=1

(1+5Z )+ 1(1−3Z )

µz=3n+(−5)n

So solution is an=3n+(−5)n