0% found this document useful (0 votes)
8 views

Tutorial Consolidated 1

The document is a tutorial sheet containing a series of algorithmic problems and tasks related to various topics in computer science, including sorting algorithms, graph theory, optimization problems, and complexity analysis. Each problem requires the formulation of algorithms, analysis of their complexities, and application of specific strategies such as backtracking, greedy methods, and dynamic programming. Additionally, it covers advanced topics like NP-completeness and approximation algorithms.

Uploaded by

Devansh Saxena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Tutorial Consolidated 1

The document is a tutorial sheet containing a series of algorithmic problems and tasks related to various topics in computer science, including sorting algorithms, graph theory, optimization problems, and complexity analysis. Each problem requires the formulation of algorithms, analysis of their complexities, and application of specific strategies such as backtracking, greedy methods, and dynamic programming. Additionally, it covers advanced topics like NP-completeness and approximation algorithms.

Uploaded by

Devansh Saxena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Tutorial Sheet

1. Describe the functionality of the following algorithm. Also compute the


total cost function for analysing its complexity.

2. Describe the functionality of the following algorithm. Also compute the


total cost function for analysing its complexity.
3. Consider a recursive sorting algorithm R that sorts the given array of n
elements in ascending order. Algorithm R recursively divides the array
into two balanced partitions based on the pivot element P. Formulate
the recurrence relation for the Algorithm R and solve the same using
recursion tree method. Verify your solution using substitution method.
4. Consider a recursive sorting algorithm R that sorts the given array of n
elements in ascending order. Algorithm R recursively divides the array
into two unbalanced partitions of sizes 1/n and 9/n respectively based
on the pivot element P. Formulate the recurrence relation for the
Algorithm R and solve the same using recursion tree method. Verify
your solution using substitution method.

5. Describe the problem of Graph colouring. Devise an algorithm to colour


the graph using brute force strategy. Use the same to determine the
minimum number of colours required to colour the following graph.
Estimate the complexity of your brute force algorithm.

6. Describe the travelling salesman problem (TSP). Devise a brute force


method to solve TSP. Use the same to find the optimal route for the
salesman who starts from city-1 of the given below graph. Estimate the
complexity of your brute force algorithm.
7. Define the Knapsack problem. Consider the knapsack of capacity 90.
The following are the weight vector (W) and associated profit vector
(P):
W=(20,60,20,50,15) and P=(20,60,20,50,15)
Construct the state space tree and apply the backtracking strategy to find
the maximum profit.

8. Define the problem of sum of subsets. Consider the following instance


of sum of subsets where sum m = 30 and number of elements n=6.
W[1:6]={5,10,12,13,15,18}. Construct the state space tree and apply
the backtracking strategy to find the solution

9. Define the Knapsack problem. Consider the knapsack of capacity 90.


The following are the weight vector (W) and associated profit vector
(P):
W=(20,60,20,50,15) and P=(20,60,20,50,15)
Construct the state space tree and apply the branch and bound strategy to
find the maximum profit.

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

12.Suppose we apply Huffman coding to an alphabet of size 4, and the


resulting tree is a perfectly balanced binary tree (one root with two
children, each of which has two children of its own). Find the maximum
frequency of any letter.

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.

18.Describe the single source shortest path algorithm that works on


nonnegative weighted edges. Discuss the complexity analysis of your
algorithm .Apply the same on the following network, assuming the
given network is an undirected graph.
Note: Consider Node s as the source node.
19.State the reduction algorithm and explain how this reduction technique
helps in proving the given problem as NP-Hard.

20.Prove that the following problems are NP-complete:


a. 3-CNF-SAT
b. Clique
c. Vertex Cover
d. Independent Set

21.Discuss the approximation algorithms for the following problems and


prove that they are polynomial time approximation algorithms.
a. Vertex cover
b. TSP
c. Set cover

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy