0% found this document useful (0 votes)
16 views16 pages

E1) CLDS Documentation D1-D10

Uploaded by

kasalesejal40
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views16 pages

E1) CLDS Documentation D1-D10

Uploaded by

kasalesejal40
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

F.Y.Bsc.

IT : CLDS Roll No : 57

PRACTICAL NO 1
SETS THEORY

A) INCLUSION EXCLUSION PRINCIPAL

Q.1 let A={1,2,3,4,5}: B={3,4,5}: C={5,6} find the AUBUC


-->function[]=IEP(A,B,C)
--> a=length(A);
--> b=length(B);
--> c=length(C);
--> AB=intersect(A,B);
--> BC=intersect(B,C);
--> AC=intersect(A,C);
--> ABC=intersect(AB,C);
--> ab=length(AB);
--> bc=length(BC);
--> ac=length(AC);
--> abc=length(ABC);
--> x=a+b+c-ab-bc-ac+abc;
--> printf("the no of element in AorBorC means A umion B union C is %d",x);
-->endfunction
-->A=[1,2,3,4,5]
A =
1. 2. 3. 4. 5.

-->B=[3,4,5]
B =
3. 4. 5.

-->C=[5,6]
C =
5. 6.
-->IEP(A,B,C)
the no of element in AorBorC means A umion B union C is 6

Q.2 let A={1,2,3,4}: B={3,4} find the AUB


-->function[]=IEP(A,B)
--> a=length(A);
--> b=length(B);
--> C=intersect(A,B);
--> c=length(C);
--> x=a+b-c;
--> printf("the no of element in AorB means A umion B is %d",x);
-->endfunction

-->A=[1,2,3,4]
A =
1. 2. 3. 4.

->B=[3,4]
B =
3. 4.

-->IEP(A,B)
the no of element in AorB means A union B is 4
F.Y.Bsc.IT : CLDS Roll No : 57

Q.3 let no of student studying German, French, English, both German and French,
both French and English, both German and English, all three languages are
45,40,50,12,14,16,4 respectively find the number of students studying at least one of
the subjects.

-->function[]=IEP(G,F,E,GF,FE,GE,GFE)
--> x=G+F+E-GF-FE-GE+GFE
--> printf("the no of student whose studying at least one subject is %d",x)
-->endfunction

-->IEP(45,40,50,12,14,16,4)
the no of student whose studying at least one subject is 97
F.Y.Bsc.IT : CLDS Roll No : 57

B)POWER SETS

Q.1 let set A={1,2,5,4,5,6} find the number of elements in the power set A.

-->function[]=ps(A)
--> a=length(A)
--> x=2^a
--> printf("the number of elements in the power set is %d",x)
-->endfunction

-->A=[1,2,3,4,5,6]
A =
1. 2. 3. 4. 5. 6.
-->ps(A)
the number of elements in the power set is 64
F.Y.Bsc.IT : CLDS Roll No : 57

PRACTICAL NO 2
FUNCTION AND ALGORITHM
A) RECURSIVE DEFINE FUNCTION

Q.1 find the value of 3! and 6!


--> function[]=fact(n)
--> prod=1
--> if(n==0)
--> prod=1;
--> else
--> while(n>0)
--> prod=n*prod
--> n=n-1
--> end
--> end
--> disp(prod)
--> endfunction
--> n=3
n =
3.
--> fact(n)
6.
--> n=6
n =
6.
--> fact(n)
720.
F.Y.Bsc.IT : CLDS Roll No : 57

B) CARDINALITY OF SETS

Q.1 let set A={2,3,5,6} find the cardinality of the set A


-->function[]=IEP(A)
--> a=length(A)
--> printf("the cardinality of the set is %d",a);
-->endfunction
-->A=[2,3,5,6]
A =
2. 3. 5. 6.
-->IEP(A)
the cardinality of the set is 4

Q.2 let set B={a,b,c,d,e} find the cardinality of the set A


--> function[]=cardinality(B,a,b,c,d,e)
--> x=length(B)
--> printf("the cardinality of the set is %d",x)
--> endfunction
--> B
B =
[1x1 constant] [1x1 constant] [1x1 constant] [1x1 constant] [1x1 constant]
--> cardinality(B,a,b,c,d,e)
the cardinality of the set is 5
F.Y.Bsc.IT : CLDS Roll No : 57

C) POLYNOMIAL EVOLUSION

Q.1 find the roots of polynomial


i)x2+2x+1=0
ii)x2+2x+2=0

--> function[]=pe(a,b,c)
--> disc=b^2-4*a*c
--> if(disc<0)
--> printf("the roots are not real and complex")
--> else
--> x1=(-b+sqrt(disc))/2*a
--> x2=(-b-sqrt(disc))/2*a
--> printf("the roots of given equation are %f and %f",x1,x2)
--> end
--> endfunction
--> pe(1,2,1)
the roots of given equation are -1.000000 and -1.000000
--> pe(1,2,2)
the roots are not real and complex
F.Y.Bsc.IT : CLDS Roll No : 57

D) GREATEST COMMON DIVISOR

Q.1 Find the gcd of 16,4


--> function[]=gcdof(a,b)
--> c=int32([a,b])
--> d=gcd(c)
--> printf(“the gcd of %d, %d is %d”a,b,d)
--> endfunction
--> gcdof(16,4)
the gcd of 16,4 is 4.
F.Y.Bsc.IT : CLDS Roll No : 57

PRACTICAL NO 5
COUNTING ONE

A) SUM RULE PRINCIPAL

Q.1 Find sum of first 20 numbers.


--> function[]=sumof()
--> sum=0
--> if(n==0)
--> sum=0
--> else while(n>0)
--> sum=n+sum;
--> n=n-1;
--> end
--> end
--> disp(sum);
--> endfunction
--> n=20
n =
20.
--> sumof()
210.
F.Y.Bsc.IT : CLDS Roll No : 57

B) PRODUCT RULE PRINCIPAL

Q.1 Find product of first 20 numbers.


--> function[]=factof()
--> prod=1
--> if(n==0)
--> prod=1;
--> else while(n>0)
--> prod=n*prod;
--> n=n-1;
--> end
--> end
--> printf("product is %f",prod);
--> endfunction
--> n=20
n =
20.
--> factof()
product is 2432902008176640000.000000
F.Y.Bsc.IT : CLDS Roll No : 57

C) FACTORIAL

Q.1 find the value of 3! and 6!


--> function[]=fact(n)
--> prod=1
--> if(n==0)
--> prod=1;
--> else
--> while(n>0)
--> prod=n*prod
--> n=n-1
--> end
--> end
--> disp(prod)
--> endfunction
--> n=3
n =
3.
--> fact(n)
6.
--> n=6
n =
6.
--> fact(n)
720.
F.Y.Bsc.IT : CLDS Roll No : 57

D) BIONOMIAL COEFFICIENT

Q.1 find bionomial coefficient of (a+b)6


--> function[]=fact(n)
--> a=factorial(n)
--> printf("bionomial coefficient are")
--> for(r=0:n)
--> c=factorial(r)
--> b=factorial(n-r)
--> d=a/(c*b)
--> printf(" %d",d)
--> end
--> endfunction
--> fact(6)
bionomial coefficient are 1 6 15 20 15 6 1
F.Y.Bsc.IT : CLDS Roll No : 57

PRACTICAL NO 6
COUNTING TWO

A) PERMUTATION

Q.1 Find value of 8P5.


--> function[]=permu(n,r)
--> a=factorial(n)
--> b=factorial(n-r)
--> permu=a/b
--> printf("%f",permu)
--> endfunction
--> permu(8,5)
6720.000000
F.Y.Bsc.IT : CLDS Roll No : 57

B) PERMUTATION WITH REPETITIONS

Q.1 In how many ways we can write the word “mississippi” with repetition of
character.
--> function[]=permu(y,z,d,f,h)
--> n=factorial(y)
--> a=factorial(z)
--> b=factorial(d)
--> e=factorial(f)
--> c=factorial(h)
--> x=n/(a*b*e*c)
--> printf("we can arrange the character in mississippi word in %d different ways.",x)
--> endfunction
--> permu(11,1,4,4,2)
we can arrange the character in mississippi word in 34650 different ways.
F.Y.Bsc.IT : CLDS Roll No : 57

C) COMBINATION

Q.1 Find value of 8C5.


--> function[]=comb(n,r)
--> a=factorial(n)
--> b=factorial(r)
--> c=factorial(n-r)
--> comb=a/(b*c)
--> printf("%f",comb)
--> endfunction
--> comb(8,5)
56.000000
F.Y.Bsc.IT : CLDS Roll No : 57

D) COMBINATION WITH REPETITIONS

Q.1 There are 8 different ice creamflavour in the ice cream shop so how many ways
can we choose 5 flavour out of this 8 flavour
--> function[]=comb(s,y)
--> n=factorial(s+y-1)
--> a=factorial(y)
--> b=factorial((s+y-1)-y)
--> x=n/(a*b)
--> printf("in %d different ways we can group the 5 flavour of ice cream out of 8.",x)
--> endfunction
--> comb(8,5)
in 792 different ways we can group the 5 flavour of ice cream out of 8.
F.Y.Bsc.IT : CLDS Roll No : 57

PRACTICAL NO 10
RECURRENCE RELATIONS

A)LINEAR HOMOGENEOUS RECURRENCE RELATIONS WITH CONSTANT


COEFFICIENTS

Q.1 an=3an-1+2an-2 n>2


an=2 n=1
an=3 n=2
find the value of a3, a4, a5, a6
--> a(1)=2;
--> a(2)=3;
--> for(n=3:6)
--> a(n)=3*a(n-1)+2*a(n-2);
--> printf("a(%d)=%d\n",n,a(n));
--> end
a(3)=13
a(4)=45
a(5)=161
a(6)=573

You might also like