DSTL Unit 5
DSTL Unit 5
Applications Graph
2. Adjacency List
Graph theory is used to find shortest path in road or a network. An array is used to store edges between two ver ces
Graphs are used to represent networks of communica on. The size of array is equal to number of ver ces.
Graphs are used to represent data organiza on. Each index in array represents a specific vertex in the graph.
The entry at the index i of the array contains a linked list Complete bipar te graphs are a special type of bipar te
containing the ver ces that are adjacent to vertex i. graph.
In a complete bipar te graph, every vertex in one set is
connected to every vertex in the other set.
Complete bipar te graphs are o en denoted as Km,n,
where m and n represent the number of ver ces in the two
disjoint sets.
Number of edges=m×n
Planar graph
Complete graph:
A complete graph is an undirected graph where every
vertex is connected to every other vertex by a unique
edge. -
The complete graph of n ver ces is denoted by Kn . Isomorphic graph
Kn has exactly n(n-1)/2 = nC2 edges Two graphs are isomorphic if and only if they have the same
number of ver ces and edges,
there exists a one-to-one correspondence between their
ver ces such that the adjacency rela on is preserved.
Bi-partite graph
Ver ces in a bipar te graph can be divided into two
disjoint sets.
No two ver ces within the same set are adjacent.
All edges connect ver ces from different sets.
Applica ons of bipar te graphs include matching
problems, network flow, social network analysis, and
recommender systems. homomorphism
homomorphism does not require a one-to-one
correspondence between vertices,
it does not necessarily preserve all structural properties
of the graphs.
It only preserves the adjacency relationships between
vertices.
Path
A path in a graph is a sequence of ver ces connected by
edges. Each vertex in the sequence is adjacent to the next
vertex in the sequence.
There are no repeated ver ces in the path.
A path can start and end at any vertex in the graph.
Permutations
Cycle Permuta ons arrangements of objects in a specific order.
Permuta ons can be with or without repe on, depending
Any closed path in a graph where the star ng and ending on whether the same object can be used mul ple mes or
ver ces are the same. not.
The number of permuta ons of n objects taken r at a me
circuit
is denoted as P(n,r) and calculated as
circuit refers to a closed path where the star ng and ending nPr=(n−r)!/n!, where n! represents the factorial of n.
ver ces are the same. Combinations
It can involve revisi ng ver ces and edges. Combina ons selec ons of items from a group where the
order doesn't ma er.
Eulerian Path: Combina ons can be with or without repe on, depending
Traverses every edge exactly once. on whether the same item can be selected mul ple mes
May visit ver ces mul ple mes. or not.
The number of combina ons of n objects taken r at a me is
Eulerian Cycle: denoted as C(n,r) and calculated as !nCr=r!(n−r)!/n!, where
n! represents the factorial of n.
Traverses every edge exactly once, forming a closed loop.
If any graph has eularian cycle then it is called eularian Ques on 1: How many different ways can you arrange the
graph le ers in the word "BOOK"?
Hamiltonian Path: Solu on 1: The word "BOOK" has 4 le ers, so the number of
permuta ons is 4!. Therefore, there are 4×3×2×1= 24 different
Visits every vertex exactly once.
ways to arrange the le ers.
It's a simple path.
Ques on 2: In how many ways can a commi ee of 3 people be
Hamiltonian Cycle: selected from a group of 7 people?
Visits every vertex exactly once, forming a closed loop. Solu on 2: This is a combina on problem. The number of ways
If any graph has Hamiltonian cycle then it is called to choose a commi ee of 3 people from a group of 7 people is
Hamiltonian graph
C(7,3)=7!/3! *(7−3)!
=7×6×5/3×2×1=35
Solu on 4: The word "APPLE" has 5 le ers, but there are two
'P's. So, the number of permuta ons is 5!/2! since the 'P's are
indis nguishable.
Pigeonhole Principle
The pigeonhole principle is some me useful in coun ng
methods.
If n pigeons are assigned to m pigeonholes then at least
one pigeonhole contains two or more pigeons (m < n).
The principle is useful for proving the existence of solu ons,
or bounding the number of solu ons.
The Pigeonhole Principle is widely applicable in various
areas of mathema cs and computer science, including
combinatorics, number theory, algorithms, and probability.