Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

EE 360C - ALGORITHMS

Lecture 1
Nur A. Touba
University of Texas at Austin

SET DEFINITIONS
Set Collection of distinguishable objects
Called members or elements
x element of set S: x S
x not element of set S: x S
Two sets equal (i.e., A = B) if
Contain exactly same elements
Special sets:
- set with no elements
Z - set of integer elements
R - set of real number elements
N - set of natural number elements

SET OPERATORS
Subset
if x A implies x B, then A B
Proper Subset
if A B and A B then A B
Intersection
A B = {x : x A and x B}
Union
A B = {x : x A or x B}
Difference
A B = {x : x A and x B}

RELATIONS DEFINTIONS
Binary Relation R on Sets A and B
Subset of Cartesian Product A B
If (a,b) R, sometimes written as a R b
Reflexive
R A A reflexive if a R a for all a A
Symmetric
R symmetric if a R b implies b R a
Transitive
R transitive if a R b and b R c imply a R c
Antisymmetric
R antisymmetric if a R b and b R a imply a = b

EQUIVALENCE RELATION
Equivalence Relation
Relation that is reflexive, symmetric, and transitive
Equivalence Class
If R equivalence relation on set A then
for a A, equivalence class of a is set
[a] = {b A : a R b}

EXAMPLE
Consider R = {(a,b) : a,b N and a + b is even number}
Is it reflexive?
Is it symmetric?
Is it transitive?

PARTIAL ORDER
Partial Order
Relation that is reflexive, antisymmetric, and
transitive
Total Order
Partial Order on A where
for all a,b A, either a R b or b R a hold

FUNCTION DEFINITIONS
Function f
Binary Relation on A B where
for a A, there exists exactly one b B such
that (a,b) F
Set A is Domain of f (a is argument to function)
Set B is Co-domain of f (b is value of function)
Function often written as
f:AB
if (a,b) F, b = f(a)
Function assigns element of B to each element of A
No a assigned to two different b
Same b can be assigned to two different a

SEQUENCE
Sequence ordered set
Finite Sequence
Function whose domain is {0, 1, , n-1}
Often written as f(0), f(1), , f(n-1)
Infinite Sequence
Function whose domain is N, set of natural numbers
When Domain of f is Cartesian Product, A=A1A2An
Often write f(a1,a2,,an) instead of f((a1,a2,,an))
Each ai called argument of f
Even though argument really n-tuple (a1,a2,,an)

FUNCTION DEFINITIONS
Image
If f : A B is function and b = f(a)
b called image of a under f
Range of f
Image of its domain (i.e., f(A))
Surjection (aka Mapping A onto B)
Function whose range is its co-domain
f(n) = n/2 surjective function from N to N
f(n) = 2n not surjective function from N to N
surjective function from N to even numbers

FUNCTION DEFINITIONS
Injection (aka one-to-one function)
Distinct arguments to f produce distinct values
a a implies f(a) f(a)
f(n) = n/2 not injective function
f(n) = 2n injective function

Bijection (aka one-to-one correspondence)


Function that is both injective and surjective

TYPES OF GRAPHS
Directed Graph (aka Digraph)
Pair (V,E) where V is finite set (vertices) and E
(edges) is subset of VV

TYPES OF GRAPHS
Undirected Graph
Pair (V,E) where V is finite set (vertices) and E
(edges) is unordered pair (u,v) where u v

PROPERTIES OF EDGES
Edge (u,v) in Diagraph
Incident from or leaves u
Incident to or enters v
v adjacent to u
Edge (u,v) in Undirected Graph
Incident to both u and v
u and v adjacent

PROPERTIES OF EDGES
Degree of Vertex in Undirected Graph
Number of edges incident to it
Same as number of adjacent vertices
In-degree of Vertex in Digraph
Number of edges entering it
Out-degree of Vertex in Digraph
Number of Edges leaving it

PATHS IN GRAPHS
Path from Vertex u to Vertex v
Sequence of vertices v0, v1, , vk
u = v0, v = vk, and (vi-1,vi) E
Path contains vertices v0, v1, , vk
Length of Path
Number of edges in path
v is reachable from u if path from u to v
Simple Path
All Vertices Distinct

PATHS IN GRAPHS
Subpath of Path P
Subset of edges in path P
Cycle in v0, v1, , vk
In Digraph
v0 = vk and k 1
Simple Cycle if all vertices distinct
In Undirected Graph
v0 = vk and k 3 and all vertices distinct
Acyclic Graph
No cycles

CONNECTIVITY IN GRAPH
Connected Undirected Graph
Each pair of vertices connected by path
Connected Components
Equivalence Class of vertices under Is Reachable
From Relation
Strongly Connected Components of Digraph
Equivalence Class of vertices under are mutually
reachable relation
Strongly Connected Directed Graph
Every two vertices reachable from one another
Exactly one strongly connected component

GRAPH ISOMORPHISM
G = (V,E) Isomorphic to G = (V,E)
If exists one-to-one function f : V V such that
(u,v) E if and only if (f(u),f(v)) E
Conceptually G relabelled to get G

SUBGRAPHS AND TRANSFORMATIONS


Graph G = (V,E) is Subgraph of G = (V,E)
If V V and E E
Given V V, Subgraph Induced by V is
G = (V, (VV) E)
or equivalently, E = {(u,v) E : u,v V}

Directed Version of Undirected Graph G = (V,E)


G = (V,E) where (u,v) E if and only if (u,v) E
Conceptually, two edges introduced for each
original edge

SUBGRAPHS AND TRANSFORMATIONS


Undirected Version of Directed Graph G = (V,E)
G = (V,E) where (u,v) E if and only if u v and
(u,v) E
Conceptually, directionality and self-loops removed

SPECIAL GRAPHS
Complete Graph
Undirected graph with every pair of vertices
adjacent
Bipartite Graph
Undirected graph in which vertex set partitioned
into two sets V1 and V2 such that every edge of
form (x,y) where x V1 and y V2
Forest Acyclic Undirected Graph
Tree Connected, Acyclic Undirected Graph
Dag Directed Acyclic Graph

SPECIAL GRAPHS

SPECIAL GRAPHS
Multigraph
Like undirected graph, but can have multiple edges
between vertices and self-loops

Hypergraph
Like undirected graph, but each hyperedge can
connect arbitrary number of vertices

TREES
Theorem (Property of Trees)
Let G = (V,E) be undirected graph
Following are Equivalent Statements
G is Tree
Any Two Vertices of G Connected by Unique
Simple Path
G is Connected, but if any edge removed from E,
resulting graph will not be connected
G is Connected and |E| = |V| - 1
G is Acyclic and |E| = |V| - 1
G is Acyclic, but if any edge added to E,
resulting graph contains cycle

ROOTED TREE

Rooted Tree
Tree in which one vertex distinguished from others
Distinguished vertex called root
Vertex in rooted tree often called node
Let r by root of rooted tree
For any node x, unique path exists from r to x
Any node y on path from r to x is ancestor of x
If y is ancestor of x, then x is descendant of y
Every node is its own ancestor and descendant
Proper ancestor (or descendant)
Ancestor (descendant) that is not node itself
Subtree rooted at x
Tree induced by decendants of x

ROOTED TREE
If last edge on path from r to x is (y,x)
y parent of x, and x child of y
Root is only node with no parent
Siblings Two nodes with same parent
Leaf Node with no children (aka external node)
Internal Node Non-leaf node
Degree of x Number of children of node x
Depth of x Length of path from r to x
Height of Tree T Largest depth of any node in T
Ordered Tree
Rooted Tree where Children at Each Node Ordered

BINARY TREES
Binary Trees (Defined Recusively)
Structure defined on finite set of nodes that either
Contain no nodes (empty or null or NIL)
Composed of three disjoint sets of nodes
Root node, left subtree, and right subtree
If left (right) subtree of binary tree non-empty
Root called left (right) child
Full Binary Tree
Each node either leaf or has degree 2

You might also like