unit - i principles of dynamics (9)

Reg.No:
SNS College of Technology,Coimbatore-35.
(Autonomous)
B.E/B.Tech- Internal Assessment -II
Academic Year 2016-2017(Even)
Fourth Semester
Computer Science and Engineering
IT204 – Design and Analysis of Algorithms
B
(Common to CSE & IT)
Time: 1
1/2
Hours
Maximum Marks: 50
Answer All Questions
PART - A (5 x 1 = 5 Marks)
CO
1.
2.
____________ is an algorithm design method that can be used when the solution to a CO3
problem can be viewed as the result of a sequence of decisions.
a) Greedy method
b) Divide and conquer method
c) Branch and bound
d) Dynamic programming
Prim’s algorithm is based on ____________ method
CO3
a) Divide and conquer method
b) Greedy method
c) Dynamic programming
Blooms
E
A
d) Branch and bound
3.
Linear Programming requires ___________
CO4
U
4.
a) Symmetric Method
b) Symbolic Approach
d) Symptoms
c) Simplex Method
A digraph satisfying Maximum-Flow properties is called a ___________
CO4
A
CO4
R
5.
a) Flow Network
b) Network
c) Pre Flow Network
d) Flow Network & Network
The last row of a simplex table is called the _______________
a) Object row
b) Objective row
c) Single row
6.
7.
d) Classified row
PART - B (5 x 2 = 10 Marks)
CO Blooms
Define optimal solution for Job sequencing with deadlines.
CO3 R
Feasible solution with maximum profit is optimal solution for Job
sequencing with deadlines.
List the features of dynamic programming.
CO3 A
 Optimal solutions to sub problems are retained so as to avoid recomputing their
values.
 Decision sequences containing sub sequences that are sub optimal are not
considered.
1

It definitely gives the optimal solution always.
CO3 E
Compare Greedy method and Dynamic programming.
Greedy method
Dynamic Programming
 Only one sequence of decision
 Many numbers of decisions
is generated
are generated.
 It does not guarantee to give an
 It definitely gives an
optimal solution always.
optimal solution
CO4 R
9. What is Source and Sink?
Source: It contains exactly one vertex with no entering edges
Sink: It contains exactly one vertex with no leaving edges
CO4 U
10. Infer Bipartite graph.
All the vertices can be partitioned into two disjoint sets V and U, not necessarily of the
same size, so that every edge connects vertices in one of these sets to vertices in the other
sets.
PART – C (14+14+7 = 35 Marks)
8.
CO
11. (a)
What is meant by OBST? Explain concept of OBST with an algorithm and 14 CO3
example.
An optimal binary search tree is a binary search tree for which the nodes are
arranged on levels such that the tree cost is minimum. For the purpose of a
better presentation of optimal binary search trees, we will consider “extended
binary search trees”, which have the keys stored at their internal nodes.
An optimal binary search tree (BST), sometimes called a weightbalanced binary tree, is a binary search tree which provides the smallest
possible search time (or expected search time) for a given sequence of
accesses (or access probabilities). Optimal BSTs are generally divided into
two types: static and dynamic.
In the static optimality problem, the tree cannot be modified after it has
been constructed. In this case, there exists some particular layout of the nodes
of the tree which provides the smallest expected search time for the given
access probabilities. Various algorithms exist to construct or approximate the
statically optimal tree given the information on the access probabilities of the
elements.
In the dynamic optimality problem, the tree can be modified at any
time, typically by permitting tree rotations. The tree is considered to have a
cursor starting at the root which it can move or use to perform modifications.
In this case, there exists some minimal-cost sequence of these operations
which causes the cursor to visit every node in the target access sequence in
order. The splay tree is conjectured to have a constant competitive ratio
compared to the dynamically optimal tree in all cases, though this has not yet
been proven.
2
Blooms
R
(or)
(b)
Construct the minimum spanning tree using Prim's & Kruskal's Algorithm 14 CO3
with an example.
Prim's
Kruskal's
3
Apply
12. (a)
(b)
Solve the given problem using simplex method.
Max z = 40x1 + 30x2
Subject to
x1 + x2 <= 16
x1 + x2 <= 9
3x1 + 2x2 <= 24
Answer: x1=4,x2=6,Z=340
(or)
14 CO4
C
Illustrate the Stable Marriage problem with the algorithm and example.
14 CO4
U
7
E
A marriage matchingM is a set of n (m, w) pairs whose members are selected
from disjoint n-element sets Y and X in a one-one fashion, i.e., each man m
from Y is paired with exactly one woman w from X and vice versa. (If we
represent Y and X as vertices of a complete bipartite graph with edges
connecting possible. Marriage partners, then a marriage matching is a perfect
matching in such a graph.)
Stable marriage algorithm
 Input: A set of n men and a set of n women along with rankings of the
women
 by each man and rankings of the men by each woman with no ties
 allowed in the rankings
 Output: A stable marriage matching
 Step 0 Start with all the men and women being free.
 Step 1 While there are free men, arbitrarily select one of them and do the
following:
 Proposal The selected free man m proposes to w, the next
 woman on his preference list (who is the highest-ranked woman
 who has not rejected him before).
 Response If w is free, she accepts the proposal to be matched
 with m. If she is not free, she compares m with her current mate. If
 she prefersm to him, she accepts m’s proposal, making her former mate
free; otherwise,
 she simply rejects m’s proposal, leaving m free.
 Step 2 Return the set of n matched pairs.
13. (a)
Determine Huffman Tree for the following
Character
A
B
C
D
_
Probability
0.35
0.1
0.2
0.2
0.15
4
CO3
(or)
(b)
Analyze the maximum-flow problem with an example.
A flow network G=(V,E): a directed graph, where each edge (u,v)E has a
nonnegative capacity c(u,v)>=0.
If (u,v)E, we assume that c(u,v)=0.
two distinct vertices :a source s and a sink t.
G=(V,E): a flow network with capacity function c.
5
7
CO4
A
s-- the source and t-- the sink.
A flow in G: a real-valued function f:V*V  R satisfying the following
two properties:
Capacity constraint: For all u,v V,
we require f(u,v)  c( u,v).
Flow conservation: For all u V-{s,t}, we require
The quantity f (u,v) is called the net flow from vertex u to vertex v.
The value of a flow is defined as
The total flow from source to any other vertices.
The same as the total flow from any vertices to the sink.
**********************
Prepared by
Verified by
6
HoD/DEAN