Tutorial Consolidated 1
Tutorial Consolidated 1
10.Consider the following state space graph in which the weights on the
edges represents the actual cost (𝑓(𝑛)) and value labelled above each
node represents the heuristic cost (𝑔(𝑛)) to the Goal node H. The total
cost at any node 𝑛 is given: 𝑇(𝑛) = 𝑓(𝑛) + 𝑔(𝑛). Use this cost
function to select the next E-node and determine the optimal search path
from source node A to the Goal node H.
11.Discuss the greedy algorithm to determine the maximum set of mutually
compatible activities from the given schedule of activities. Also discuss
the optimal substructure and greedy choice property for the same.
Analyze the complexity of the algorithm. Apply the same to determine
the optimal set of mutually compatible activities from the following
schedule of activities:
Activity A1 A2 A3 A4 A5 A6 A7 A8 A9 A10
Start Time 0 2 1 4 6 8 14 9 14 5
Finish Time 5 5 6 5 13 9 20 14 16 8
13.Assume that the numbers given below represent counts of letters in the
hundreds from a file For example, in the file there will be exactly 20 *
100 occurrences of the letter ‘a’ , 11*100 occurrence of the letter ‘c’,
etc. a: 20, c:11, d:2, e: 10, o:15, m:8, s:10, t:22, u: 2
a. What is an optimal Huffman code based on the following set of
frequencies? Draw the tree.
b. Determine the percentage of saving in the file size using Huffman
code when compared to fixed length code.
14.Given a set of integers, the task is to divide it into two sets S1 and S2
such that the absolute difference between their sums is minimum.
If there is a set S with n elements, then if we assume Subset1 has m
elements, Subset2 must have n-m elements and the value of
abs(sum(Subset1) – sum(Subset2)) should be minimum.
Input: arr[] = {1, 6, 11, 5}
Output: 1
Explanation: S1 = {1, 5, 6}, sum = 12, S2 = {11}, sum = 11, Absolute
Difference (12 – 11) = 1
a. Define the optimal substructure
b. Formulate the recurrence relation
c. Design the bottom-up approach to find the solution
d. Determine the optimal solution
15.Subset sum problem: Given a set of non-negative integers and a
value sum, the task is to check if there is a subset of the given set whose
sum is equal to the given sum. Devise a dynamic programming based
algorithm to solve the subset sum problem and analyze its complexity.
Also apply the algorithm to solve the following instance of the problem:
Set= {3, 4,5,2}, sum = 6
a. Define the optimal substructure
b. Formulate the recurrence relation
c. Design the bottom-up approach to find the solution
d. Determine the optimal solution
16.Determine the minimum spanning tree for the following network using
kruskal’s and prim’s algorithm:
16.Determine the minimum spanning tree for the following network using
kruskal’s and prim’s algorithm:
17.Discuss the max flow min- cut algorithm to determine the maximum
flow of the given flow network. Analyze the running time of the
algorithm. Apply the algorithm on the following flow network to
determine the maximum flow from source s to sink t.