Algorithms
Algorithms
SOLUTION 2023
Group- A
(Very Short Answer Type Question)
Answer any ten of the following:
of
) State
True/False: Approximation algorithm guaranties the best quality
solution.
Chapter Name: «APPROXIMATION ALGORITHMS"
Answer: False
Polynomial Algorithm.
v) State True/False: Ordered searching algorithm is a PROBLEMS"
Chapter Name: "TRACTABLE AND INTRACTABLE
Answer: False
quality of solution.
vi)State True/False: Brute Force method gives the bestSTRATEGIES"
ALGORITHMIC
Chapter Name: "FUNDAMENTAL
Answer: True
DAA-153
POrULAR PUBLICATIONS
6
24
3
0/8
DAA-154
DESIGN AND ANALYSIS OL ALKORITIIMS
Write down an algorithm in Greedy method to find the maximum spanning tree
byprim's algorithm. What is the time complexity of your algorithm?
Answer:
Referrto
to "GRAPHAND TREE TRAVERSAL ALGORITHMS"; Long Answer
2.
DypeQuestion No.
theorem.
6.a)State Cook's
b)Define Clique with example.
Chapterl Name: "TRACTABLE AND INTRACTABLEPROBLEMS"
Answer:
) Refer toSlhort Answer Type Question No, 7.
Refer to Short Answer Type Question No. 3.
6. Define the following terms:
(i) Brute force algorithm
(ii) Approximation Algorithm
Answer:
STRATEGIES"; Short Answer
) Refer to "FUNDAMENTAL ALGORITHMIC
Type Question No. 20. ALGORITHMS": Long Answer Type
i) Refer to APPROXIMATION
Question No. 1(4).
Group-C
(Long Answer Type Question)
minimum spanning tree using Prim's method from the following
7. a) Find the
graph. Mention each step clearly.
28
10
14 16
7 3
24
5 18 12
ALGORITHMIC
b)& Refer to "FUNDAMENTAL
Answer Type Question No. 15(b).
d) Algorithm
For a graph with Nvertices:
STRATEGIES
Step 1: Initialize the shortestpaths between any 2 vertices with Infinity
vertices, then
Step 2: Find all pair shortest paths that use Ointermediate all Nvertices find fhe
using
paths that use Iintermediate vertex and so on.. until
nodes.
Minimizethe shortest paths between any 2pairs in the previous
Step 4:3: For any 2vertices (i,j),one should actually minimize the distances
Step Toperatetrieonk
pair using the first Knodes, so the shortest path will dist[i1]
be: min(o
the shortest path between the pair k,j. As the shortest path be a [k+didsistt[|\|KkIi0b)
dist[i][k] represents the shortest path that only uses the firstwillKvertices.
shortest path from i to k, then from k to j.
for (int k = 1; k <= n; k++) {
concatenation
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
dist [i) G1 = min( ist [i] [jl, dist [i][k] +
dist (ki51
)
min (All+ A24 +10x$*5, A12 +A34 + 10×20x$> 6736, A13 +A44
Ox20×5)
spanning tree
Write
down an algorithm using Greedy method to find minimum
by
) Krushkal'salgorithm.
Answer: Long Answer
RefertoGRAPH AND TREE TRAVERSAL ALGORITH
ipe Question No. 8(c).
c)
Findthe time complexity of your algorithm.
Answer:
ALGORITHMS"; Long Answer
AND
Referto "GRAPH 7. TREE TRAVERSAL
No.
TypeQuestion
Bound.
Differentiate between Backtracking and Branch and STRATEGIES"
d)
Chapter Name: FUNDAMENTAL ALGORITHMIC
Answer:
Backtracking Branch and Bound
Parameter solve
find alllBranch-and-Bound is used to
Approach Backtracking is used to problems. When it
possible solutions available to aloptimisation
that it already has a better
problem. When it realises that itl realises solution that the pre-solution
|has made a bad choice, it undoesoptimal
to, it abandons that pre-solution.
the last choice by backing it up. Itlleads searches the state space
|searches the state space tree untilIt completely
optimal solution.
it has found a solution for theltree to get
problem. traverse the tree n
stateBranch-and-Bound
Traversal Backtracking traverses the
manner, DFS or BFS.
space tree by DFS(Depth Firstany
|Search) manner. involves a
Solution
|lead to bad choice. solution.
On successful search of solution| Entire always
state space tree
|in state space tree, search stops. to find optimal
DAA-158
ALCORITHHMS
DESIGN AND ANALYSS OF
are
undirected graph is graph, i.e., a set of objects
(called vertices or nodes) that
An
nccted together, where all the edges are bidirectional, An
undirected graph is
Onetimescalled.an undirected network. ofthe
vertex, the number of head ends adjacent to a vertex is calledtheindegree
) For a
and (called branching
the number of tail ends adjacent to a vertex is its outdegree
ertex
etorintrees).
vertex and
W)Avertex
is said to be an articulation point in a graph if removal of the increases
points
ssociated edges disconnectsthe graph. So, the removal of articulation sometimes
number of connected
the cutvertices.
components in a graph. Articulation points are
lled
disconnects the
Anedgein an undirected connected graph is a bridge if removing itbridgeis an edge
Paph. Foraa disconnected undirected graph,the definition is similar, a
removalthat increases the number of disconnected components.
11.a)
Differentiate between recursion and iteration. using Master's
b)Find thhe time complexity of the following recurrence relations
Theorem.
(0)
DAA-159
POPULARPUBLICATIONS
Property Recursion
Speed Execution is slow since it has the Normally, it is
overhead of maintaining and as it doesn't utilizee t
Itefraastteiron
Memory
updating the stack. the sta
Kecursion uses more memory as Iteration uses less
compared tto recursion
|compared to iteration.
Overhead Possesses overhead of repeated|No overhead as
Infinite
function calls. calls in iteration.
If the recursive function does not| If the control
there ar
Repetition meet to a termination condition oriteration
the base case is not defined or is false or the statementCondtnei
never reached then it leads. to a reach the Control
terminationVarvabe
stack overflow error and there is a will cause
crash in infinite recursion. again and again.
infinite theooyC
chance that the an system may infinite loop, it uses
b)i) T(o)=2r|+T()=o(")
+log.n
For this recurrence relation we have a=(2),b =2 and f(n)= log, n. Thus
nn=() Since f(n)=o()=0 Vn) and thus the solutio
recurrence is T(n)=0(log, n).
c) Refer to Long Answer Type Question No. I.