For
For
DISCRETE M
DISCRETE MATHEMATICS
ATHEMATICS
(IT 504)
(IT 504)
B.Tech (IT)
B.Tech (IT)
SEM V
SEM V
June 2010
June 2010
Faculty of Technology
Faculty of Technology
Dharmsinh Desai University
Dharmsinh Desai University
Nadiad.
Nadiad.
www.ddu.ac.in
www.ddu.ac.in
Write a program to find intersection set of two sets ... 8 Write a program to find intersection set of two sets ... 8
EXPERIMENT-2 EXPERIMENT-2
Wri
Write te a a program to program to fifind nd uniunion on set oset of two f two sets sets ... ... 99
EXPERIMENT-3 EXPERIMENT-3
Write a program to find Compliment set of the given set... 10 Write a program to find Compliment set of the given set... 10
EXPERIMENT-4 EXPERIMENT-4
Write a program to find difference set of two sets ... 11 Write a program to find difference set of two sets ... 11
EXPERIMENT-5 EXPERIMENT-5
Write a program to find symmetric difference set of two sets ... 12 Write a program to find symmetric difference set of two sets ... 12
EXPERIMENT-6 EXPERIMENT-6
Write a program to prove the D’Morgan’s Laws of set theory ... 13 Write a program to prove the D’Morgan’s Laws of set theory ... 13
EXPERIMENT-7 EXPERIMENT-7
Write a program to find the power set of the given set ... 14 Write a program to find the power set of the given set ... 14
EXPERIMENT-8 EXPERIMENT-8
Wri
Write te a a program to program to fifind nd permupermutation of tation of the set ... the set ... 1515
EXPERIMENT-9 EXPERIMENT-9
Wri
Write te a a program to program to imimplemenplement t BinaBinary Search ry Search ... ... 1616
EXPERIMENT-10 EXPERIMENT-10
Find the
Find the cardinality cardinality of the of the set and set and prove prove |A |A U B U B U C| U C| = |A= |A| + | + |B| + |B| + |C| |C| - |A- |A∩ B|∩ B|- |B- |B∩ C|∩ C| - |A- |A
∩ C| + |A ∩ B ∩ C|
∩ C| + |A ∩ B ∩ C|……….17……….17
LABWORK BEYOND CURRICULA LABWORK BEYOND CURRICULA EXPERIMENT-11
EXPERIMENT-11
Wri
Write te a a program to program to genegenerate rate PascalPascal’s ’s TrianTriangle ... gle ... 1818
EXPERIMENT-12 EXPERIMENT-12
Implement Bubblesort Algorithm and Largest2 Algorithm ... 19 Implement Bubblesort Algorithm and Largest2 Algorithm ... 19
Sample Experiment Sample Experiment 1 AIM:
1 AIM: Write a program to implement DMorgan’s Law. Write a program to implement DMorgan’s Law.
2 TOOLS:
2 TOOLS: Turbo c++ Turbo c++
3 STANDARD PROCEDURES: 3 STANDARD PROCEDURES:
3.1 Analyzing the Problem: 3.1 Analyzing the Problem:
To Implement DMorgan’s law we have to
To Implement DMorgan’s law we have to verify the equation of DMorgan’s Lawverify the equation of DMorgan’s Law (AUB)’=A’ (AUB)’=A’∩B’.∩B’. Step1 Step1 Suppose Taking U= {1, 2, 3, 4, 5} Suppose Taking U= {1, 2, 3, 4, 5} A= {1, 3} A= {1, 3} B= {1, 4, 6} B= {1, 4, 6} Step2 Step2
Union of A and B AUB= {1,
Union of A and B AUB= {1, 3, 4, 6}3, 4, 6} Step3
Step3
Complement
Complement of of AUB AUB is is (AUB)’ (AUB)’ = = {2, {2, 5}5} Complement of A is A’= {2, 4, Complement of A is A’= {2, 4, 5}5} Complement of B is B’= {2, 3, Complement of B is B’= {2, 3, 5}5} Step4 Step4
Intersection of A’ and B’ A’
Intersection of A’ and B’ A’∩B’= {2, 5}∩B’= {2, 5}
3.2 Designing the Solution: 3.2 Designing the Solution:
To design the solution of Dmorgan’s law we need
To design the solution of Dmorgan’s law we need to implement following three mainto implement following three main Functions
Functions
1.
1. UnionUnion
x=No. of element in set A x=No. of element in set A y=No. of element in set B y=No. of element in set B O[]=output set
O[]=output set
int union(int x,int y,int m[],int n[],int o[]) int union(int x,int y,int m[],int n[],int o[]) {{ for(int j=0;j<y;j++) for(int j=0;j<y;j++) {{ for(int i=0;i<x;i++) for(int i=0;i<x;i++) {{ if(n[j]==m[i]) if(n[j]==m[i]) {{ break; break;
}} else else
o[ptr++]=n[j]; /*add element to union set*/ o[ptr++]=n[j]; /*add element to union set*/ /* return union sets*/
/* return union sets*/ }}
}}
2.
2. IntersectionIntersection
int intersection(int x,int y,int
int intersection(int x,int y,int m[],int n[],int o[])m[],int n[],int o[]) {{ for(int j=0;j<y;j++) for(int j=0;j<y;j++) {{ for(int i=0;i<x;i++) for(int i=0;i<x;i++) {{ if(m[i]==n[j]) if(m[i]==n[j])
o[ptr++]=n[j]; /* add element to intersection set.*/ o[ptr++]=n[j]; /* add element to intersection set.*/ /* return intersection sets*/
/* return intersection sets*/ }} }} }} 3. 3. ComplimentCompliment int compliment(int x
int compliment(int x,int y,int m,int y,int m[],int n[],int [],int n[],int o[])o[]) {{ for(in for(int t j=0;j<x;j+j=0;j<x;j++)+) {{ for(int i=0;i<y;i++) for(int i=0;i<y;i++) {{ if(n[i]==m[j]) if(n[i]==m[j]) {{ break; break; }} else else o[ptr++]=m[j
o[ptr++]=m[j]; /*add e]; /*add element to compliment set*/lement to compliment set*/ /* return compliment of set*/
/* return compliment of set*/ }}
3.3 Implementing the Solution 3.3 Implementing the Solution
3.3.1 Writing Source Code 3.3.1 Writing Source Code
#include<iostream.h> #include<iostream.h> #include<conio.h> #include<conio.h> void main() void main() {{ clrscr(); clrscr(); int a[100],b[100],u[100], c[10
int a[100],b[100],u[100], c[100],d[100],e[100],g[100],f0],d[100],e[100],g[100],f[100],n,m,l;[100],n,m,l; int ptr=0,ptr1=0,ptr2=0,ptr4=0,ptr3=0;
int ptr=0,ptr1=0,ptr2=0,ptr4=0,ptr3=0; int
int cpl(int,int,incpl(int,int,int *,int *,it *,int *,int *);nt *); int intr(int,in
int intr(int,int,int t,int *,int *,int * );*,int *,int * ); int uni(int,int,int *,int *,int * ); int uni(int,int,int *,int *,int * ); void print (int *,int);
void print (int *,int); int get(int *);
int get(int *);
cout<<"enter how many element
cout<<"enter how many element in U:";in U:"; n=get(u);
n=get(u);
cout<<"enter how many element
cout<<"enter how many element in A:";in A:"; m=get(a);
m=get(a);
cout<<"enter how many element in B:"; cout<<"enter how many element in B:"; l=get(b);
l=get(b); cout<<"\n\n"<<"Uni
cout<<"\n\n"<<"Union oon of A & B is: ";f A & B is: "; ptr= uni (m,l,a,b,c);
ptr= uni (m,l,a,b,c); print(c,ptr);
print(c,ptr);
cout<<"\n\n"<<"complement of A union B cout<<"\n\n"<<"complement of A union B is: ";is: "; ptr4= cpl(n,ptr,u,c,g); ptr4= cpl(n,ptr,u,c,g); print(g,ptr4); print(g,ptr4); cout<<"\n\n"<<"complement of A is: "; cout<<"\n\n"<<"complement of A is: "; ptr1=cpl(n,m,u,a,d); ptr1=cpl(n,m,u,a,d); print(d,ptr1); print(d,ptr1); cout<<"\n\n"<<"complement of B is: "; cout<<"\n\n"<<"complement of B is: "; ptr2=cpl(n,l,u,b,e); ptr2=cpl(n,l,u,b,e);
print(e,ptr2); print(e,ptr2);
cout<<"\n\n"<<"intersection of A'& B' is: "; cout<<"\n\n"<<"intersection of A'& B' is: "; ptr3=intr(ptr1,ptr2,d,e,f); ptr3=intr(ptr1,ptr2,d,e,f); print(f,ptr3); print(f,ptr3); getch(); getch(); }}
int cpl(int x,int y,int m[],in
int cpl(int x,int y,int m[],int n[],int t n[],int o[]) /* function which perform complement of two sets*/o[]) /* function which perform complement of two sets*/ {{ int flag=1,ptr=0; int flag=1,ptr=0; for(int j=0;j<x;j++) for(int j=0;j<x;j++) {{ for(int i=0;i<y;i++) for(int i=0;i<y;i++) {{ if(n[i]==m[j]) if(n[i]==m[j]) {{ flag=0; flag=0; break; break; }} else else flag=1; flag=1; }} if(flag==1) if(flag==1) o[ptr++]=m[j]; o[ptr++]=m[j]; }} return ptr; return ptr; }}
int intr(int x,int y,int m[],int n[],int o[]) /* function which perform intersection of two sets*/ int intr(int x,int y,int m[],int n[],int o[]) /* function which perform intersection of two sets*/ {{
int ptr=0; int ptr=0;
for(int j=0;j<y;j++) for(int j=0;j<y;j++)
for(int i=0;i<x;i++) for(int i=0;i<x;i++) {{ if(m[i]==n[j]) if(m[i]==n[j]) o[ptr++]=n[j]; o[ptr++]=n[j]; }} }} return ptr; return ptr; }}
int uni(int x,int y,int m[],int n[],int o[]) /* function which perform union of two
int uni(int x,int y,int m[],int n[],int o[]) /* function which perform union of two sets*/sets*/ {{ int flag=1,ptr=0; int flag=1,ptr=0; for(int j=0;j<x;j++) for(int j=0;j<x;j++) o[ptr++]=m[j]; o[ptr++]=m[j]; for( j=0;j<y;j++) for( j=0;j<y;j++) {{ for(int i=0;i<x;i++) for(int i=0;i<x;i++) {{ if(n[j]==m[i]) if(n[j]==m[i]) {{ flag=0; flag=0; break; break; }} else else flag=1; flag=1; }} if(flag==1) if(flag==1) o[ptr++]=n[j]; o[ptr++]=n[j]; }} return ptr; return ptr; }}
void print(int o[],int ptr) /* function for printing output*/ void print(int o[],int ptr) /* function for printing output*/
{{ cout<<"{ "; cout<<"{ "; for(int i=0;i<ptr;i++) for(int i=0;i<ptr;i++) cout<<o[i]<<" "; cout<<o[i]<<" "; cout<<"}"; cout<<"}"; }} int
int get(int get(int o[]) o[]) / / * f* function function for takinor taking input*/g input*/ {{ int n; int n; cin>>n; cin>>n; cout<<"enter element:"; cout<<"enter element:"; for(int i=0 ;i<n;i++) for(int i=0 ;i<n;i++) cin>>o[i];
cin>>o[i]; return n; return n; }}
3.3.2 Compilation /Running and Debugging the Solution 3.3.2 Compilation /Running and Debugging the Solution
3.4 Testing the Solution 3.4 Testing the Solution
4 Conclusions 4 Conclusions
So Compliments of union of two sets
So Compliments of union of two sets is equal to compliment of intersection of two sets is ais equal to compliment of intersection of two sets is a Dmorgan’s law
EXPERIMENT-1 EXPERIMENT-1
Aim: Write a program to find intersection set of two sets. Aim: Write a program to find intersection set of two sets. Tools / Apparatus:
Tools / Apparatus:
O.S.: Microsoft Windows (any) / Linux / DOSO.S.: Microsoft Windows (any) / Linux / DOS
Packages: Turbo/Borland/GNU - C/C++Packages: Turbo/Borland/GNU - C/C++
Data Structure: Array, Linked lists Data Structure: Array, Linked lists Programming Techniques:
Programming Techniques:
Using Pointers and passing the compared values to Using Pointers and passing the compared values to particular string.particular string.
Using the concept of recursion, to continuously check the equality of elements inUsing the concept of recursion, to continuously check the equality of elements in the array.
the array.
By transferring the elements of the one array (set) to the other and comparingBy transferring the elements of the one array (set) to the other and comparing them.
them.
By checking the redundancy in the data by combining them into one array andBy checking the redundancy in the data by combining them into one array and later transferring them to
later transferring them to another array.another array.
Overview: Overview:
In discrete mathematical (set theory) terminology intersection means, the intersection set In discrete mathematical (set theory) terminology intersection means, the intersection set of two sets is the set, which conta
of two sets is the set, which contains the common elements that exist in botins the common elements that exist in both sets.h sets. For Example,
For Example, A
A = = {1, {1, 2, 2, 3, 3, 4, 4, 5} 5} B B = = {3, {3, 4, 4, 5, 5, 6}6} Then intersection set of A and B Then intersection set of A and B is,is,
A^B = Common elements of A and B = {3, 4, 5} A^B = Common elements of A and B = {3, 4, 5}
EXPERIMENT-2 EXPERIMENT-2
Aim: Write a program to find union set o
Aim: Write a program to find union set of two sets.f two sets. Tools / Apparatus:
Tools / Apparatus:
O.S.: Microsoft Windows (any) / Linux / DOSO.S.: Microsoft Windows (any) / Linux / DOS
Packages: Turbo/Borland/GNU - C/C++Packages: Turbo/Borland/GNU - C/C++
Data Structure: Array, Linked lists Data Structure: Array, Linked lists Programming Techniques:
Programming Techniques:
Using Pointers and passing the compared values to Using Pointers and passing the compared values to particular strinparticular string.g.
Using the concept of recursion, to continuously check the equality of elements inUsing the concept of recursion, to continuously check the equality of elements in the array.
the array.
By transferring the elements of the one array (set) to the other and comparingBy transferring the elements of the one array (set) to the other and comparing them.
them. Overview:
Overview:
In discrete mathematical (set theory) terminology union means, the union set of two sets In discrete mathematical (set theory) terminology union means, the union set of two sets is the set, which contains the elements t
is the set, which contains the elements that are in either of set.hat are in either of set. For Example,
For Example, A
A = = {1, {1, 2, 2, 3, 3, 4, 4, 5} 5} B B = = {3, {3, 4, 4, 5, 5, 6}6} Then union set of A and B is,
Then union set of A and B is,
AUB = elements either in A or B = {1, 2, 3, 4, 5, 6} AUB = elements either in A or B = {1, 2, 3, 4, 5, 6}
EXPERIMENT-3 EXPERIMENT-3
Aim: Write a program to find Complement set of the g
Aim: Write a program to find Complement set of the given set.iven set. Tools / Apparatus:
Tools / Apparatus:
O.S.: Microsoft Windows (any) / Linux / DOSO.S.: Microsoft Windows (any) / Linux / DOS
Packages: Turbo/Borland/GNU - C/C++Packages: Turbo/Borland/GNU - C/C++
Data Structure: Array, Linked lists Data Structure: Array, Linked lists Programming Techniques:
Programming Techniques:
Using Pointers and passing the compared values to Using Pointers and passing the compared values to particular strinparticular string.g.
Using the concept of recursion, to continuously check the equality of elements inUsing the concept of recursion, to continuously check the equality of elements in the array.
the array.
By transferring the elements of the one array (set) to the other and comparingBy transferring the elements of the one array (set) to the other and comparing them.
them.
By checking the redundancy in the data by combining them into one array andBy checking the redundancy in the data by combining them into one array and later transferrin
later transferring them to g them to another array.another array.
Overview: Overview:
In discrete mathematical (set theory) terminology ‘compliment’ means, the compliment In discrete mathematical (set theory) terminology ‘compliment’ means, the compliment set of the given set is the set which contains the elements which are in the universal set but not set of the given set is the set which contains the elements which are in the universal set but not present in the given set.
present in the given set. For Example, For Example, U
U = = {1, {1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10} 10} A A = = {3, {3, 4, 4, 5, 5, 6}6} Then compliment set of A,
Then compliment set of A, A’ = elements, which are not
A’ = elements, which are not in A but present in Universal set of A.in A but present in Universal set of A. = {1, 2, 7, 8, 9, 10}
EXPERIMENT-4 EXPERIMENT-4
Aim: Write a program to find difference set of two sets. Aim: Write a program to find difference set of two sets. Tools / Apparatus:
Tools / Apparatus:
O.S.: Microsoft Windows (any) / Linux / DOSO.S.: Microsoft Windows (any) / Linux / DOS
Packages: Turbo/Borland/GNU - C/C++Packages: Turbo/Borland/GNU - C/C++
Data Structure: Array, Linked lists Data Structure: Array, Linked lists Programming Techniques:
Programming Techniques:
Using Pointers and passing the compared values to Using Pointers and passing the compared values to particular strinparticular string.g.
Using the concept of recursion, to continuously check the equality of elements inUsing the concept of recursion, to continuously check the equality of elements in the array.
the array.
By transferring the elements of the one array (set) to the other and comparingBy transferring the elements of the one array (set) to the other and comparing them.
them.
By checking the redundancy in the data by combining them into one array andBy checking the redundancy in the data by combining them into one array and later transferring them to
later transferring them to another array.another array.
Overview: Overview:
In discrete mathematical (set theory) terminology difference means, the difference set of In discrete mathematical (set theory) terminology difference means, the difference set of two sets (say A and B) is the set which contains the elements which are in the set A but not in two sets (say A and B) is the set which contains the elements which are in the set A but not in A^B. A^B. For Example, For Example, A A = = {1, {1, 2, 2, 3, 3, 4, 4, 5} 5} B B = = {3, {3, 4, 4, 5, 5, 6}6} Then difference set of A and B
Then difference set of A and B is,is,
A - B = elements in A but not in A^B = {1, 2} A - B = elements in A but not in A^B = {1, 2}
EXPERIMENT-5 EXPERIMENT-5
Aim: Write a program to find symmetric difference set of two sets. Aim: Write a program to find symmetric difference set of two sets. Tools / Apparatus:
Tools / Apparatus:
O.S.: Microsoft Windows (any) / Linux / DOSO.S.: Microsoft Windows (any) / Linux / DOS
Packages: Turbo/Borland/GNU - C/C++Packages: Turbo/Borland/GNU - C/C++
Data Structure: Array, Linked lists Data Structure: Array, Linked lists Programming Techniques:
Programming Techniques:
Using Pointers and passing the compared values to Using Pointers and passing the compared values to particular strinparticular string.g.
Using the concept of recursion, to continuously check the equality of elements inUsing the concept of recursion, to continuously check the equality of elements in the array.
the array.
By transferring the elements of the one array (set) to the other and comparingBy transferring the elements of the one array (set) to the other and comparing them.
them.
By checking the redundancy in the data by combining them into one array andBy checking the redundancy in the data by combining them into one array and later transferring them to
later transferring them to another array.another array.
Overview: Overview:
In discrete mathematical (set theory) terminology symmetric difference means, the In discrete mathematical (set theory) terminology symmetric difference means, the symmetric difference set of two sets (say A and B) is the set which contains the elements which symmetric difference set of two sets (say A and B) is the set which contains the elements which are in the set A and in set B but not in A^B.
are in the set A and in set B but not in A^B. For Example,
For Example, A
A = = {1, {1, 2, 2, 3, 3, 4, 4, 5} 5} B B = = {3, {3, 4, 4, 5, 5, 6}6} Then symmetric difference set of A and B Then symmetric difference set of A and B isis,, A
EXPERIMENT-6 EXPERIMENT-6
Aim: Write a program to prove the D’Morgan’s Laws o
Aim: Write a program to prove the D’Morgan’s Laws of set theory.f set theory. Tools / Apparatus:
Tools / Apparatus:
O.S.: Microsoft Windows (any) / Linux / DOSO.S.: Microsoft Windows (any) / Linux / DOS
Packages: Turbo/Borland/GNU - C/C++Packages: Turbo/Borland/GNU - C/C++ Data Structure: Array, Linked lists
Data Structure: Array, Linked lists Programming Techniques:
Programming Techniques:
Use the prepared functions those must have been made in earlier experiments and shouldUse the prepared functions those must have been made in earlier experiments and should use them accordingly when needed to prove the theorems. (i.e. union(…), use them accordingly when needed to prove the theorems. (i.e. union(…), intersection(…), co
intersection(…), complimmpliment(…))ent(…))
Storing the value/outcome of LHS in one string and comparing that with another string,Storing the value/outcome of LHS in one string and comparing that with another string, which contains the value/outcome of RHS.
which contains the value/outcome of RHS.
Using Pointers and passing the compared values tUsing Pointers and passing the compared values to particular string.o particular string.
Using the concept of recursion, to continuously check the equality of elements in theUsing the concept of recursion, to continuously check the equality of elements in the array.
array.
By transferring the elements of the one array (set) to the By transferring the elements of the one array (set) to the other and comparing them.other and comparing them.
By checking the redundancy in the data by combining them into one array and laterBy checking the redundancy in the data by combining them into one array and later transferring them to another array.
transferring them to another array. Overview:
Overview:
In discrete mathematical (set theory) terminology the D’Morgan’s Laws are given below (for set In discrete mathematical (set theory) terminology the D’Morgan’s Laws are given below (for set A and B),
A and B), (A^B)’
(A^B)’ = = A’ A’ U U B’ B’ --- --- (1)(1) (AUB)’
(AUB)’ = = A’ A’ ^ ^ B’ B’ --- --- (2)(2) Equations (1) and (2) describe the D’Morgan’s Laws
Equations (1) and (2) describe the D’Morgan’s Laws for the set theory.for the set theory.
The programmer should check the validity of these two equations by using the programming The programmer should check the validity of these two equations by using the programming techniques given above.
techniques given above. For Example, For Example, A
A = = {1, {1, 2, 2, 3, 3, 4, 4, 5} 5} B B = = {3, {3, 4, 4, 5, 5, 6, 6, 7} 7} U U = = {1, {1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9}9} A^B
A^B = = {3, {3, 4, 4, 5} 5} (A^B)’ (A^B)’ = = {1, {1, 2, 2, 6, 6, 7, 7, 8, 8, 9} 9} --- --- (1)(1) A’
A’ = = {6, {6, 7, 7, 8, 8, 9} 9} B’ B’ = = {1, {1, 2, 2, 8, 8, 9} 9} A’UB’ A’UB’ = = {1, {1, 2, 2, 6, 6, 7, 7, 8, 8, 9} 9} – – (2)(2) From (1) and (2) the first law is proved.
EXPERIMENT-7 EXPERIMENT-7
Aim: Write a program to find the power
Aim: Write a program to find the power set of the given set.set of the given set. Tools / Apparatus:
Tools / Apparatus:
O.S.: Microsoft Windows (any) / Linux / DOSO.S.: Microsoft Windows (any) / Linux / DOS
Packages: Turbo/Borland/GNU - C/C++Packages: Turbo/Borland/GNU - C/C++
Data Structure: Array, Linked lists Data Structure: Array, Linked lists Programming Techniques:
Programming Techniques:
Using Pointers and passing the compared values tUsing Pointers and passing the compared values to particular string.o particular string.
Combining each value with the all other value respective of the concept of the Power set.Combining each value with the all other value respective of the concept of the Power set.
Make one feature to tMake one feature to tackle the power set of the ‘Empty set’.ackle the power set of the ‘Empty set’.
Using the concept of recursion, to continuously check the equality of elements in theUsing the concept of recursion, to continuously check the equality of elements in the array.
array.
By transferring the elements of the one array (set) to the By transferring the elements of the one array (set) to the other and comparing theother and comparing them.m.
By checking the redundancy in the data by combining them into one array and laterBy checking the redundancy in the data by combining them into one array and later transferring them to another array.
transferring them to another array.
Print the power set as a Print the power set as a single set whose elements are also sets.single set whose elements are also sets.
Overview: Overview:
In discrete mathematical (set theory) terminology the ‘Power set’ means, the set of all subsets of In discrete mathematical (set theory) terminology the ‘Power set’ means, the set of all subsets of a set (say A) is called subset (o
a set (say A) is called subset (of A).f A). For Example,
For Example, A = {1, 2, 3, 4, 5} A = {1, 2, 3, 4, 5}
Power set of A = P(A) =
EXPERIMENT-8 EXPERIMENT-8
Aim: Write a program to find permutation of the set. Aim: Write a program to find permutation of the set. Tools / Apparatus:
Tools / Apparatus:
O.S.: Microsoft Windows (any) / Linux / DOSO.S.: Microsoft Windows (any) / Linux / DOS
Packages: Turbo/Borland/GNU - C/C++Packages: Turbo/Borland/GNU - C/C++
Data Structure: Array, Linked lists Data Structure: Array, Linked lists Programming Techniques:
Programming Techniques:
Use the concept of subset and use them according to different combination and also byUse the concept of subset and use them according to different combination and also by considering the avoidance of dup
considering the avoidance of duplicate data in terms of its subsets.licate data in terms of its subsets.
Also by using the concept Also by using the concept of factorial for sets.of factorial for sets.
Using Pointers and passing the compared values tUsing Pointers and passing the compared values to particular string.o particular string.
Using the concept of recursion, to continuously check the equality of elements in theUsing the concept of recursion, to continuously check the equality of elements in the array.
array.
By transferring the elements of the one array (set) to the By transferring the elements of the one array (set) to the other and comparing them.other and comparing them.
By checking the redundancy in the data by combining them into one array and laterBy checking the redundancy in the data by combining them into one array and later transferring them to another array.
transferring them to another array. Overview:
Overview:
In discrete mathematical (set theory) terminology the permutation means, the power set of a In discrete mathematical (set theory) terminology the permutation means, the power set of a particular
particular given given set set contains contains the the collection collection of of sets sets of of different different permuted permuted subsets subsets and and theirtheir combinations.
EXPERIMENT-9 EXPERIMENT-9
Aim: Write a program to implement Binary Search. Aim: Write a program to implement Binary Search. Tools / Apparatus:
Tools / Apparatus:
O.S.: Microsoft Windows (any) / Linux / DOSO.S.: Microsoft Windows (any) / Linux / DOS
Packages: Turbo/Borland/GNU - C/C++Packages: Turbo/Borland/GNU - C/C++
Data Structure: Array, Linked lists Data Structure: Array, Linked lists Programming Techniques:
Programming Techniques:
By using the robust algorithm of binary search and tBy using the robust algorithm of binary search and then implement it for the sets.hen implement it for the sets.
Check whether the data Check whether the data is in sorted order or not and if not tis in sorted order or not and if not then sort those data.hen sort those data.
Use the concepts of low, high and mid design your algorithm and them implement it withUse the concepts of low, high and mid design your algorithm and them implement it with any of technique described below.
any of technique described below.
Using Pointers and passing the compared values tUsing Pointers and passing the compared values to particular string.o particular string.
Using the concept of recursion, to continuously check the equality of elements in theUsing the concept of recursion, to continuously check the equality of elements in the array.
array. Overview: Overview:
In discrete mathematical (set theory) terminology the permutation means, the power set of a In discrete mathematical (set theory) terminology the permutation means, the power set of a particular
particular given given set set contains contains the the collection collection of of sets sets of of different different permuted permuted subsets subsets and and theirtheir combinations.
EXPERIMENT-10 EXPERIMENT-10
Aim: Find the cardinality of the set
Aim: Find the cardinality of the set and proveand prove |A U B U C| = |A| + |B| + |C| - |A
|A U B U C| = |A| + |B| + |C| - |A ∩ B|∩ B| - |B- |B∩ C|∩ C|- |A- |A∩ C| + |A ∩ B ∩ C|∩ C| + |A ∩ B ∩ C|
Tools / Apparatus: Tools / Apparatus:
O.S.: Microsoft Windows (any) / Linux / DOSO.S.: Microsoft Windows (any) / Linux / DOS
Packages: Turbo/Borland/GNU - C/C++Packages: Turbo/Borland/GNU - C/C++
Data Structure: Array, Linked lists Data Structure: Array, Linked lists Programming Techniques:
Programming Techniques:
Using Pointers and passing the compared values tUsing Pointers and passing the compared values to particular string.o particular string.
Using the concept of recursion, to continuously check the equality of elements in theUsing the concept of recursion, to continuously check the equality of elements in the array.
array.
By checking the redundancy in the data by combining them into one array and laterBy checking the redundancy in the data by combining them into one array and later transferring them to another array.
transferring them to another array. Overview:
Overview:
In discrete mathematical (set theory) terminology union means, the union set of two sets is the In discrete mathematical (set theory) terminology union means, the union set of two sets is the set, which contains the elements that
set, which contains the elements that are in either of set.are in either of set. For Example,
For Example, A
A = = {1, {1, 2, 2, 3, 3, 4, 4, 5} 5} B B = = {3, {3, 4, 4, 5, 5, 6} 6} C= C= {4, {4, 7, 7, 8};8}; Then union set of A and B is,
Then union set of A and B is,
|AUBUC| = elements either in A or
EXPERIMENT-11 EXPERIMENT-11
Aim: Write a program to generate Pascal’s Triangle. Aim: Write a program to generate Pascal’s Triangle. Tools / Apparatus:
Tools / Apparatus:
O.S.: Microsoft Windows (any) / Linux / DOSO.S.: Microsoft Windows (any) / Linux / DOS
Packages: Turbo/Borland/GNU - C/C++Packages: Turbo/Borland/GNU - C/C++
Data Structure: Array, Linked lists Data Structure: Array, Linked lists Programming Techniques:
Programming Techniques:
Using Pointers and passing the compared values tUsing Pointers and passing the compared values to particular string.o particular string.
Using the concept of recursion, to continuously check the equality of elements in theUsing the concept of recursion, to continuously check the equality of elements in the array.
array.
By checking the redundancy in the data by combining them into one array and laterBy checking the redundancy in the data by combining them into one array and later transferring them to another array.
transferring them to another array. Overview:
Overview:
For given elements limit, draw the Pascal’s triangle as For given elements limit, draw the Pascal’s triangle as
11
11 11
11 2 2 11
1 3 3 1
EXPERIMENT-12 EXPERIMENT-12
Aim: Implement Bubble sort
Aim: Implement Bubble sort AlgoriAlgorithm and thm and Largest2 Algorithm.Largest2 Algorithm. Tools / Apparatus:
Tools / Apparatus:
O.S.: Microsoft Windows (any) / Linux / DOSO.S.: Microsoft Windows (any) / Linux / DOS
Packages: Turbo/Borland/GNU - C/C++Packages: Turbo/Borland/GNU - C/C++
Data Structure: Array, Linked lists Data Structure: Array, Linked lists Programming Techniques:
Programming Techniques:
Using Pointers and passing the compared values tUsing Pointers and passing the compared values to particular string.o particular string.
Using the concept of recursion, to continuously check the equality of elements in theUsing the concept of recursion, to continuously check the equality of elements in the array.
array.
By checking the redundancy in the data by combining them into one array and laterBy checking the redundancy in the data by combining them into one array and later transferring them to another array.
transferring them to another array. Overview:
Overview:
Do the following for i=0, 1, 2 …n-1..Compare the numbers in registers xi and xi+1. PlaceDo the following for i=0, 1, 2 …n-1..Compare the numbers in registers xi and xi+1. Place the larger of the two
the larger of the two numbers in register xi+1 and the smaller in register xi.numbers in register xi+1 and the smaller in register xi.
References References
Reference Books Reference Books
Object Oriented Programming by Robert Object Oriented Programming by Robert LaforeLafore