Академический Документы
Профессиональный Документы
Культура Документы
Asymptotic Analysis:
Big –O Notation:
T(n) is said to be in O(f(n)) when T(n) is bounded by a constant multiple of f(n). So we can say
T(n)<= c.f(n) where c is a constant.
Big-Ὼ Notation:
This gives us the lower bound on the running times of an algorithm. We would want to prove for
this that T(n) is at least a constant multiple of some specific function f(n). T(n)>= € . f(n) is the
statement in order to show the lower bound on the algorithm.
Big-ϴ Notation:
This gives the asymptotically tight bound on the running times of an algorithm. If a function is
said to be in both O(f(n)) and Ὼ(f(n)) we can say that T(n) is ϴ(f(n)).
Asymptotically tight bounds on worst-case performances of an algorithm is desirable to
characterize it.
Graph :
A graph G may be defined as a collection of vertices and edges,G=(V,E). The edges in the graph
are used to connect the different vertices with one another. The edges may be directed or
undirected and based on that may be called as directed or undirected graph.
Breadth – First Search Algorithm :
The algorithm uses a queue data structure to store intermediate results as it traverses the graph,
as follows:
The time complexity of this algorithm may be expressed as O|V|+O|E| since every vertex and
edge will be visited in the worst case scenario and space complexity may be O|V|.
DFS(s):
If Explored[u]=false then
Set explored[u]=true
End for
End if
End while
Topological Ordering:
Topological ordering of vertices in a directed graph is an ordering of vertices such that for every
directed edge uv from vertex u to vertex v, u comes before v in the ordering.
4. In any connected undirected graph, there is a vertex whose removal leaves the graph
connected.
Proof:
Consider any directed graph G=(V,E). Let us do depth first search on the graph G and construct a
tree form that named ‘T’. Let us denote the leaves of the tree as Leaves(T). If we choose any
vertex v ∈ Leaves(T), then removal of that particular vertex from the tree and the edges
associated with it will still keep the tree ‘T’ connected (by the definition of tree). Thus Tˆ = T -
{v} is connected which goes on to imply that the graph Gˆ=(V-{v},E-{(i, j) : i = v ∨ j = v}) is
still connected because Tˆ and Gˆ are isomorphic to each other.
5. DAG:
Algorithm:
Let us say s and t are the nodes with indegree and outdegree as zero.
Algorithm –
For(x = s to t)
For (x+1 to c)
For (z+1 to t)
If(discovered[node]==true)
Then exit
Else
Go to Next Node
Return discovered[node]=true