0% found this document useful (0 votes)
52 views

Fafl Assignment Name: Prabhakar Gouda Assignment No: 01,02,03 Roll No: 35 Week No: 01 SEM: V Cs&E Section: B

This document contains an assignment submission for Prabhakar Gouda. It includes sections on set theory, graph theory, and their related concepts. The document provides definitions and examples for topics like sets, unions, intersections, graphs, vertices, edges, and graph variations. It aims to demonstrate understanding of fundamental mathematical structures and their representations.

Uploaded by

Prabhakar Gouda
Copyright
© Attribution Non-Commercial (BY-NC)
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)
52 views

Fafl Assignment Name: Prabhakar Gouda Assignment No: 01,02,03 Roll No: 35 Week No: 01 SEM: V Cs&E Section: B

This document contains an assignment submission for Prabhakar Gouda. It includes sections on set theory, graph theory, and their related concepts. The document provides definitions and examples for topics like sets, unions, intersections, graphs, vertices, edges, and graph variations. It aims to demonstrate understanding of fundamental mathematical structures and their representations.

Uploaded by

Prabhakar Gouda
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 12

FAFL ASSIGNMENT

NAME : PRABHAKAR GOUDA ASSIGNMENT NO : 01,02,03


ROLL NO : 35 WEEK NO : 01
SEM : V CS&E SECTION : B

1
Contents

0.1 Graphical representation of Daily Routine. . . . . . . . . . . . 3


0.2 SET THEORY . . . . . . . . . . . . . . . . . . . . . . . . . . 4
0.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4
0.2.2 Basic Operations with Sets . . . . . . . . . . . . . . . . 4
0.2.3 Set-theoretic equalities . . . . . . . . . . . . . . . . . . 6
0.3 Graph Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
0.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . 6
0.3.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 7
0.3.3 Graph Variations . . . . . . . . . . . . . . . . . . . . . 8
0.3.4 Applications of Graph . . . . . . . . . . . . . . . . . . 8
0.3.5 Isomorphism . . . . . . . . . . . . . . . . . . . . . . . . 9
0.3.6 Connectivity . . . . . . . . . . . . . . . . . . . . . . . . 10

2
0.1 Graphical representation of Daily
Routine.
Consider the set NODES
W:wokeup
B:breakfast
C:college
Li:library
L:launch
D:dinner
S:sleeping
Q={W,B,C,Li,L,D,S}
P
={t1,t2,t3,t4 .. . . tn} Different input times.
q0=W The initial state.
F={S}
We can represent the graph as:

Figure 1: graph

3
0.2 SET THEORY
0.2.1 Introduction
Sets are collections. The objects in the collection are its members.
E.g., we are all members of the set of all humans.
Anything can be in a set. There are sets of numbers, people, other sets.

Notation: we write names of sets like this:


{0,1} The set containing 0 and 1

{Ted, {New York City}, 57} The set containing me, the
set containing just NYC, and the
number 57

{0, 1, 2, ..} The set containing all the natural numbers


(note: this set has infinitely many members.)

{x: x is an even number}

The set containing the even numbers (i.e., {0, 2, 4, ...})

Its often intuitive to speak of collecting things together and putting them
into a set, but the idea is that the sets exist whether or not anyone has ever
done any collection. Moreover, notice that a sets members dont need to be
similar, or thought of by people, or anything like that. Except for certain
limitations well discuss later, any objects form a set.

0.2.2 Basic Operations with Sets


Union
Let A and B be sets.
S
The union of A and B is the set, denoted by A B, whose elements are
exactly those sets belonging to A or belonging to B.
For example, {0, 1, 2} ∪ {4, 5} = {0, 1, 2, 4, 5}

Intersection
Let A and B be sets.
T
The intersection of A and B is the set, denoted by A B, whose elements

4
are exactly those sets belonging to both A and B.
For example,{0, 1, 2} ∩ {1, 2, 3, 4, 5, 6, 7, 8} = {1, 2}

Difference
Let A and B be sets.
The (relative) difference of A with B is the set, denoted by A - B, whose
elements are exactly those elements of A which do not belong to B.
For example, {0, 1, 2} - {1, 2, 3} = {0}.

Complement
Complement of set A relative to set U,denoted by Ac , is the set of all
members of U that are not members of A. This terminology is most commonly
employed when U is a universal set. This operation is also called the set
difference of U and A, denoted U - A.
The complement of {1,2,3} relative to {2,3,4} is {4},
while, conversely, the complement of {2,3,4} relative to {1,2,3} is {1}.

Catesian Product
Let A and B are sets, Cartesian product of A and B, denoted A X B, is the
set whose members are all possible ordered pairs (a,b) where a is a member
of A and b is a member of B.
For example,The Cartesian product of {0, 1, 2} and {3, 4} is
{{0, {0, 3}}, {0, {0, 4}}, {1, {1, 3}}, {1, {1, 4}}, {2, {2, 3}}, {2, {2, 4}}}.
The product of {3, 4} and {0, 1, 2} is
{{3, {0, 3}}, {3, {1, 3}}, {3, {2, 3}}, {4, {0, 4}}, {4, {1, 4}}, {4, {2, 4}}}.
Thus the Car- tesian product is not commutative.

Power set
The power set of a set A is the set whose members are all possible subsets of
A.
For example, the powerset of {1, 2} is { {}, {1}, {2}, {1,2} }.

Empty set
A set which has no elements is called an empty set or null set and is denoted
by { } or φ.For example the set S that does not contain any element can be
represented as,
S ={ } or S = φ

5
Subset
A set A is a subset of B if every element of A is in B and is denoted by A⊆B
If A ⊆ B and B contain an element which is not in A,th A is a proper subset
of B and is denoted by A ⊂ B.

Equal set
The two sets A and B are same iff A ⊆ B and B ⊆ A i.e.,every element of
set A is in B and every element is in B are the elements of A.

0.2.3 Set-theoretic equalities


There are a number of general laws about sets which follow from the def-
initions of set- theoretic operations, subsets, etc. A useful selection of these
is shown below. They are grouped under their traditional names. These
equations below hold for any sets X, Y, Z:
1 Idempotent Laws
(a) X ∪ X = X (b) X∩X=X
2 Commutative Laws
(a) X ∪ Y = Y ∪ X (b) X∩Y=Y∩X
3 Associative Laws
(a) (X ∪ Y) ∪ Z = X ∪ (Y ∪ Z) (b) (X ∩ Y) ∩Z = X (Y Z)
4 Distributive Laws
(a) X ∪ (Y ∩ Z) = (X ∪ Y) ∩ (X ∪ Z) (b) X ∩ (Y ∪ Z) = (X ∩ Y) ∪ (X ∩ Z)
5 Identity Laws
(a) X ∪ φ = X (b) X∪U=U
(c) X ∩ φ = φ (d) X∩U=x
6 Complement Laws
(a) X ∪ X = U (b)(X) = X
(c) X ∩ X = φ (d) X Y=X∩Y
7 DeMorgans Laws
(a) (X ∪ Y) = X ∩ Y (b) (X ∩ Y) = X ∪ Y
8 Consistency Principle
(a) X ⊆ Y iff X ∪ Y = Y (b) X ⊆ Y iff X ∩ Y = X

0.3 Graph Theory


0.3.1 Introduction
Informally, a graph is a bunch of dots connected by lines. Here is an example
of a graph:

6
Sadly, this definition is not precise enough for mathematical discussion.

Figure 2: simple graph

Formally, a graph is a pair of sets (V, E), where:


V is a nonempty set whose elements are called vertices.
E is a collection of twoelement subsets of V called edges.
The vertices correspond to the dots in the picture, and the edges correspond
to the lines. Thus, the dotsandlines diagram above is a pictorial representa-
tion of the graph (V, E) where: V = {A, B, C, D, E, F, G}
E = {{A, B} , {A, C} , {B, D} , {C, D} , {C, E} , {E, F } , {E, G} } .

0.3.2 Definitions
A nuisance in first learning graph theory is that there are so many definitions.
They all correspond to intuitive ideas, but can take a while to absorb. Some
ideas have multi ple names. For example, graphs are sometimes called net-
works, vertices are sometimes called nodes, and edges are sometimes called
arcs. Even worse, no one can agree on the exact meanings of terms.
For example, in our definition, every graph must have at least one vertex.
However, other authors permit graphs with no vertices. (The graph with
no vertices is the single, stupid counterexample to many wouldbe theorems
so were banning it!) This is typical; everyone agrees moreorless what each
term means, but dis agrees about weird special cases. So do not be alarmed
if definitions here differ subtly from definitions you see elsewhere. Usually,
these differences do not matter.

Hereafter, we use AB to denote an edge between vertices A and B rather


than the set notation A, B. Note that AB and BA are the same edge, just
as A, B and B, A are the same set.

7
Two vertices in a graph are said to be adjacent if they are joined by an
edge, and an edge is said to be incident to the vertices it joins. The number
of edges incident to a vertex is called the degree of the vertex. For example,
in the graph above, A is adjacent to B and B is adjacent to D, and the edge
AC is incident to vertices A and C. Vertex H has degree 1, D has degree 2,
and E has degree 3.

Deleting some vertices or edges from a graph leaves a subgraph. Formally,


a subgraph of G = (V, E) is a graph G = (V,E ) where V is a nonempty
subset of V and E is a subset of E. Since a subgraph is itself a graph, the
endpoints of every edge in E must be vertices in V.

0.3.3 Graph Variations


There are many variations on the basic notion of a graph. Three particularly
common variations are described below. In a multigraph, there may be more
than one edge be tween a pair of vertices. Here is an example:

Figure 3: multigraph

The edges in a directed graph are arrows pointing to one endpoint or the
other.

Directed graphs are often called digraphs. We denote an edge from vertex
A to vertex B in a digraph by A B. Formally, the edges in a directed graph
are ordered pairs of vertices rather than sets of two vertices. The number
of edges directed into a vertex is called the indegree of the vertex, and the
number of edged directed out is called the outdegree.

8
One can also allow selfloops, edges with both endpoints at one vertex.

Combinations of these variations are also possible; for example, one could
work with directed multigraphs with selfloops.

Except where stated otherwise, the word graph in this course refers to a
graph without mul tiple edges, directed edges, or selfloops.

0.3.4 Applications of Graph


Graphs are the most useful mathematical objects in computer science. You
can model an enormous number of realworld systems and phenomena using
graphs. Once youve created such a model, you can tap the vast store of
theorems about graphs to gain insight into the system youre modeling. Here
are some practical situations where graphs arise:

Data Structures Each vertex represents a data object. There is a di-


rected edge from one object to another if the first contains a pointer or
reference to the second.

Attraction Each vertex represents a person, and each edge represents a


romantic attrac tion. The graph could be directed to model the unfortunate
asymmetries.

Airline Connections Each vertex represents an airport. If there is a


direct flight be tween two airports, then there is an edge between the corre-
sponding vertices. These graphs often appear in airline magazines.

The Web Each vertex represents a web page. Directed edges between
vertices represent hyperlinks.

People often put numbers on the edges of a graph, put colors on the ver-
tices, or add other ornaments that capture additional aspects of the phe-
nomenon being modeled. For example, a graph of airline connections might
have numbers on the edges to indicate the duration of the corresponding
flight. The vertices in the attraction graph might be colored to indicate the
persons gender.

9
Some Common Graphs
Some graphs come up so frequently that they have names. The complete graph
on n vertices, also called Kn , has an edge between every pair of vertices.
Here is K5 :

Figure 4: regular graph

The empty graph has no edges at all.

0.3.5 Isomorphism
Two graphs that look the same might actually be different in a formal
sense. For example, the two graphs below are both cycles with 4 vertices:

Figure 5: Isomorphism

10
But one graph has vertex set {A, B, C, D} while the other has vertex set
{1, 2, 3, 4}. If so, then the graphs are different mathematical objects, strictly
speaking. But this is a frustrating distinction; the graphs look the same!

0.3.6 Connectivity
In the diagram below, the graph on the left has two pieces, while the graph
on the right has just one.

Figure 6: Non connected and Connected graphs

Lets put this observation in rigorous terms. A graph is connected if for


every pair of vertices u and v, the graph contains a path with endpoints u
and v as a subgraph. The graph on the left is not connected because there
is no path from any of the top three vertices to either of the bottom two
vertices. However, the graph on the right is connected, because there is a
path between every pair of vertices.

A maximal, connected subgraph is called a connected component. (By


maximal, we mean that including any additional vertices would make the
subgraph disconnected.) The graph on the left has two connected compo-
nents, the triangle and the single edge. The graph on the right is entirely
connected and thus has a single connected component.

11
PROGRAM TO GENERATE ALL POSSIBLE STRINGS OUT
OF GIVEN INPUT:
C Program:generate.c
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int count;
void perm(char *ns,char * org,int l)
{

int i,til;
char *a;
printf(”\n s”,ns);
til=strlen(ns);
count++;
if(til>=l)
return;
a=(char *)malloc(strlen(ns)+2);
strcpy(a,ns);
a[til+1]=’\0’;
for(i=0;i¡strlen(org);i++)
{

a[til]=org[i];
perm(a,org,l);
}

free(a);
return; } int main()
{
char org[50];
int len;
printf(C̈HARACTERS : ”);scanf(”s”,org);
printf(M̈ax Length : ”);
scanf(”d”,&len);
perm(””,org,len);
printf(”\n d Permutations found\n”,count);
}

12

You might also like