0% found this document useful (0 votes)
6 views61 pages

CS8451 Design and Analysis of Algorithms Pagenumber

The document provides an overview of algorithms, including definitions, types, and analysis techniques. It covers algorithm efficiency, complexities (time and space), design techniques, and various algorithmic problem types. Additionally, it discusses asymptotic notations, recursive algorithms, and methods for analyzing algorithm performance.

Uploaded by

Anurag Shekhar
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)
6 views61 pages

CS8451 Design and Analysis of Algorithms Pagenumber

The document provides an overview of algorithms, including definitions, types, and analysis techniques. It covers algorithm efficiency, complexities (time and space), design techniques, and various algorithmic problem types. Additionally, it discusses asymptotic notations, recursive algorithms, and methods for analyzing algorithm performance.

Uploaded by

Anurag Shekhar
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/ 61

PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

CS 8451- DESIGN AND ANALYSIS OF ALGORITHM S


UN IT I
INTRODUCTION

Notion of an Algorithm – Fundamentals of Algorithmic Problem Solving – Important Problem


Types – Fundamentals of the Analysis of Algorithmic Efficiency –Asymptotic Notations and
their properties. Analysis Framework – Empirical analysis – Mathematical analysis for
Recursive and Non-recursive algorithms – Visualization
PART - A

1. What do you mean by algorithm? (Nov/Dec 2008) (May/June 2013) (Apr/May 17) (U)
An algorithm is a sequence of unambiguous for solving a problem i.e., for obtaining a required
output for any legitimate input in a finite amount of time. In addition, all algorithms must satisfy
the following criteria:
1) Input
2) Output
3) Definiteness
4) Finiteness
5) Effectiveness.

2. What is performance measureme nt? (R)


Performance measurement is concerned with obtaining the space and the time
requirements of a particular algorithm.

3. Give the diagram representation of Notion of algorithm. (C)

PROBLEM

ALGORITHM

INPUT COMPUTER OUTPUT

4. What are the types of algorithm efficiencies? (R)


The two types of algorithm efficiencies are .Time efficiency: indicates how fast the
algorithm runs .Space efficiency: indicates how much extra memory the algorithm needs.

5. What is space complexity? (Nov/Dec 2012) (R)


Space Complexity indicates how much extra memory the algorithm needs. Basicallyit has
three components. They are instruction space, data space and environment space.

6. What is time complexity? (Nov/Dec 2012) (R)


Time Complexity indicates how fast an algorithm runs. T (P) =Compile Time + Run Time.(Tp)
,Where Tp is no of add, sub, mul...

IIYEAR/IV SEMESTER

1
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

7. What is an algorithm design technique? (R)


An algorithm design technique is a general approach to solving problems algorithmically that is
applicable to a variety of problems from different areas of computing.

8. What is pseudo code? (R)


A pseudo code is a mixture of a natural language and programming language constructs to
specify an algorithm. A pseudo code is more precise than a natural language and its usage often
yields more concise algorithm descriptions.

10. What are the types of algorithm efficiencies? (R)


The two types of algorithm efficiencies are
Time efficiency: indicates how fast the algorithm runs
Space efficiency: indicates how much extra memory the algorithm needs.

11. What are the steps involved in the analysis framework? (R)
The various steps are as follows
 Measuring the input‘s size
 Units for measuring running time
 Orders of growth
 Worst case, best case and average case efficiencies

12. What do you mean by “worst-case efficiency” of and algorithm? (R) (Nov 17)
The worst case efficiency of an algorithm, its efficiency for the worst-case input of size n,
which is an input or inputs of size n for which the algorithm runs the longest among all possible
inputs of that size.

13. What is best-case efficiency? (R)


The best-case efficiency of an algorithm is its efficiency for the best-case input of size n,
which is an input or inputs for which the algorithm runs the fastest among all possible inputs of
that size.

14. What is average case efficiency? (May 2008) (R)


The average case efficiency of an algorithm is its efficiency for an averagecase input of
size n. It provides information about an algorithm behavior on a ―typical‖ or ―random‖ input.

15. Define asymptotic notations. (R)


To choose best algorithm, we need to check efficiency of each algorithm the efficiency
can be measured by computing time complexity of each algorithm. Asymptotic notation is
shorthand way to represent the time complexity
The various notations are Big ―Oh‖, Big Omega, and Theta.

16. Define the asymptotic notation “Big oh” (0)(May 2008)(April/May 2012&2013) (R)
Let, f(n) and g(n) be two non-negative functions. Let, n0 and constant c are two integers such
that no denotes some value of input similarly c is constant such that c > 0. We can write

IIYEAR/IV SEMESTER

2
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

F(n) <= c*g(n) For all n ≥ n0


A function t(n) is said to be in O(g(n)) denoted t(n) ε O (g(n)), if t(n) is bounded above by some
constant multiple of g(n) for all large n, i.e., if there exist some positive constant c and some
non-negative integer n0 such that
T (n) < c g (n) for n > n0

17. Define the asymptotic notation “Omega” ( Ω). (R)


A function f(n) is said to be in Ω (g(n)) if f(n) is bounded below by some
positive constant multiple of g(n) such that
f(n) ≥ c * g(n) For all n ≥ n0

18. Define the asymptotic notation “theta” (θ) (R)


Let, f(n) and g(n) be two non negative functions. There are two positive constants namely c 1 and
c2 such that c1 ≤ g(n) ≤ c2 g(n)
Then we can say that, f(n) ε Θ (g(n))

19. What is recursive algorithm? (R)


An algorithm is said to be recursive if the same algorithm is invoked in the body. An algorithm
that calls itself is direct recursive.

20. Define recurrence. (May2010) (R)


A recurrence is an equation or inequality that describes a function in terms of its value on
smaller inputs. The complexity of many interesting algorithms is easily expressed as a
IIYEAR/IV SEMESTER

3
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

recurrence, especially divide and conquer algorithms. The complexity of recursive algorithms
is readily expressed as a recurrence.
Example :(i)Linear search of a list

1 for n  1
T (n)  
(ii) Binary
T(n -1) + 1 otherwise
 search
1 for n  1
T (n)  
T(n/2) + 1 otherwise

21. Define Linear Search. (Nov/Dec 2011) (April/May 2010&2012) (R)


In computer science, linear search or sequential search is a method for finding aparticular value
in a list, which consists in checking every one of its elements, one at atime and in sequence, until
the desired one is found.

22. What are the Best, Worst and Average Case complexity of Linear Search? (R)
 Best Case – O(1)
 Average Case – O(N)
 Worst Case – O(N)

23. Difference between Best Case and Worst Case Complexities.(AN)


The best case complexity of an algorithm is its efficiency for the best case input ofsize N,
which is an input of size N for which the algorithm runs fastest among all possible inputs of that
size.
The worst case complexity of an algorithm is its efficiency for the worst case inputof size
N, which is an input of size N for which the algorithm runs longest among all possible inputs of
that size.

24. Give the general plan for analyzing non recursive algorithm. (R)
 Decide a parameter indicating an Input‘s Size.
 Identify the algorithms Basic Operation
 Check whether the number of times the basic operation is executed only on thesize of an
input. If it also depends on some additional property, the worst case, average case, and if
necessary, best case efficiencies have to be investigated separately.
 Using standard formulas and rules of sum manipulation either find a closedformula for
the count or, at the very least, establish its order of growth.

25. What is validation of algorithm? (Nov/Dec 2012) (R)


The process of measuring the effectiveness of an algorithm before it is coded to know the
algorithm is correct for every possible input. This process is called validation.
26. What are all the methods available for solving recurrence relations? (R)
 Forward Substitution
 Backward Substitution
 Smoothness Rule
 Master Theorem

IIYEAR/IV SEMESTER

4
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

27. Write down the problem types.(April/May 2008) (R)


 Sorting
 Searching
 String Processing
 Graph Problem
 Combinational Problem
 Geometric Problem
 Numerical Problem

28. What are the types of recurrence relations? (R)


 Homogeneous recurrence relation.
 Non homogeneous recurrence relation.

29. Define Substitution Method. (April /May 2010) (R)


Substitution method is a method of solving a system of equations wherein one of
theequations is solved for one variable in terms of the other variables.

30. Give the general plan for analyzing recursive algorithm. (R)
 Decide a parameter indicating an Input‘s Size.
 Identify the algorithms Basic Operation
 Check whether the number of times the basic operation is executed only on thesize of an
input. If it also depends on some additional property, the worst case,average case, and if
necessary, best case efficiencies have to be investigatedseparately.
 Set up a recurrence relation, with an appropriate initial condition, for thenumber of times
basic operation is executed.

31. Define Recurrence Relation. (APRIL/MAY 2010) (Nov/Dec 2016) (R)


The equation defines M (N) not explicitly, ie.., is a function of n, but implicitly as afunction of
its value at another point, namely N-1. Such equations are calledrecurrence relation.

32. Give the General Plan for the Empirical Analysis of Algorithm Time Efficiency? (C)
1. Understand the experiment‘s purpose.
2. Decide on the efficiency metric M to be measured and the measurement unit (an
operation count vs. a time unit).
3. Decide on characteristics of the input sample (its range, size, and so on).
4. Prepare a program implementing the algorithm (or algorithms) for the experimentation.
5. Generate a sample of inputs.
6. Run the algorithm (or algorithms) on the sample‘s inputs and record the data observed.
7. Analyze the data obtained.

33. Write an algorithm to check whether the given string is Palindrome or not. (NOV/DEC
2008) (C)
1. Get the number from user.
2. Reverse it.
3. Compare it with the number entered by the user.
IIYEAR/IV SEMESTER

5
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

4. If both are same then print palindrome number


5. Else print not a palindrome number.

34. Write an algorithm to find the number of binary digits in the binary representation of a
positive decimal integer. (MAY 2015) (C)
ALGORITHM Binary(n)
//Input: A positive decimal integer n
//Output: The number of binary digits in n‘s binary representation
count<- 1
while n>1 do
count<- count+1
n<- [n/2]
return count

35. Write down the properties of asymptotic notations?(MAY 2015) (R)


If t1(n)Ɛ O(g1(n)) and t2(n)Ɛ O(g2(n)), then
t1(n)+t2(n)Ɛ O(max{g1(n),g2(n)})

36. Give the Euclid algorithm for computing gcd(m, n) (MAY/JUN 2016) (Apr/May 17)
(APR 17) (C)
ALGORITHM Euclid_gcd(m, n)
//Computes gcd(m, n) by Euclid‘s algorithm
//Input: Two nonnegative, not-both-zero integers m and n
//Output: Greatest common divisor of m and n
while n ≠ 0 do
r ←m mod n
m←n
n←r
return m
Example: gcd(60, 24) = gcd(24, 12) = gcd(12, 0) = 12.

37. Compare the order of growth n(n-1)/2 and n2.(MAY/JUN 2016) (AN)

n n(n-1)/2 n2

Polyno mi a l Quadratic Quadratic


1 0 1
2 1 4
4 6 16
8 28 64
10 45 102
2
10 4950 104
Complexity Low High
Grow th Low high
n(n-1)/2 is lesser than the half of n2

IIYEAR/IV SEMESTER

6
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

38. Design an algorithm for computing area and circumference of the circle. (NOV/DEC
2016) (C)
//Computes area and circumference of the circle
//Input: One non-negative integer radius
//Output: Area and Circumference of the circle

Area = PI * rad * rad;


Ci = 2 * PI * rad;
return area, ci

39. How to measure an algorithm running time? (NOV/DEC 2017) (R)


One possible approach is to count the number of times each of the algorithm‘s operation
is executed. The thing to do is identify the most important operation of the algorithm called as
basic operation and compute the number of times the basic operation is executed.
T(n)  Cop C(n)

40. What is a basic operation? (APR/MAY 2018) (R)


The process of identify the most important operation of the algorithm called as basic
operation

41.What are the applications of Algorithm Visualization?


The applications of Algorithm Visualizations are Research and Education.

42.What are two principal variations of algorithm visualization?


1)Static algorithm visualization
2)Dynamic algorithm visualization, also called algorithm animation

43.Define Algorithm Visualization?


Algorithm visualization and can be defined as the use of images to convey some useful
information about algorithms. That information can be a visual i lustration of an algorithm‘s
operation, of its per-formance on different kinds of inputs, or of its execution speed versus that of
other algorithms for the same problem.

44. Define algorithm. List the desirable properties of an algorithm. (NOV/DEC 2018)
An algorithm is a sequence of unambiguous for solving a problem i.e., for obtaining a required
output for any legitimate input in a finite amount of time. In addition, all algorithms must satisfy
the following criteria:
1) Input
2) Output
3) Definiteness
4) Finiteness
5) Effectiveness.
Properties:
1.Non-ambiquity
2.Range of input
3.Multiplicity
IIYEAR/IV SEMESTER

7
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

4.Speed
5.Finiteness

45.Define best,worst,average case time complexity. (NOV/DEC 2018)


Best case: In the best case analysis, we calculate lower bound on running time of an algorithm.
We must know the case that causes minimum number of operations to be executed.
Worst case: In the worst case analysis, we calculate upper bound on running time of an
algorithm. We must know the case that causes maximum number of operations to be executed.
Averge case: In average case analysis, we take all possible inputs and calculate computing time
for all of the inputs. Sum all the calculated values and divide the sum by total number of inputs.

46.How do you measure the efficiency of an algorithm. (APR/MAY 2019)


Time efficiency - a measure of amount of time for an algorithm to execute.
Space efficiency - a measure of the amount of memory needed for an algorithm to execute.

47. Define algorithm with its properties. (APRIL/MAY 2021)


An algorithm is a sequence of unambiguous for solving a problem i.e., for obtaining a required
output for any legitimate input in a finite amount of time. In addition, all algorithms must satisfy
the following criteria:
1) Input
2) Output
3) Definiteness
4) Finiteness
5) Effectiveness.
Properties:
1.Non-ambiquity
2.Range of input
3.Multiplicity
4.Speed
5.Finiteness

48. List the reasons for choosing an approximate algorithm. (APRIL/MAY 2021)

1. To understand the basic idea of the problem.


2. To find an approach to solve the problem.
3. To improve the efficiency of existing techniques.
4. To understand the basic principles of designing the algorithms.

PART B
1. Define the asymptotic notations used for best case average case and worst case analysis?
(APIRL/MAY2009)(APRIL/MAY-2008)(R) (Apr 18)
2. How do you evaluate the performance of the algorithms? (E)

3. Explain the general framework for analyzing the efficiency of algorithm. (R)

4. Explain properties of BIG (oh) Notation.(8) (MAY 2016) (R) (Nov 17)
IIYEAR/IV SEMESTER

8
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

5. What is meant by recurrence? Give one example to solve recurrence equations.


(APRIL/MAY 2012) (r)

6. (i) Distinguish between Big Oh, Theta and Omega natation. (NOV/DEC 2012) (AN)
(ii) Analyze the best, worst and average case analysis for linear search.

7. Find complexity of algorithm C (n) of the algorithm for the best, worst, average
case,(evaluate average case complexity of n=3 n mean number of inputs.) (E)

8. (i) Define Asymptotic notations. Distinguish between Asymptotic notation and Conditional
asymptotic notation. (10)(APRIL/MAY 2010)(APRIL/MAY 2011) (Apr/May 17)
ii) Explain how the removing condition is done from the conditional asymptotic notation with
an example. (6)(NOV/DEC 2011) (R)

9. (i) Explain how analysis of linear search is done with a suitable illustration. (10)
(ii) Define recurrence equation and explain how solving recurrence equations are done.(6)
(NOV/DEC 2011) (R)

10. Explain how Time Complexity is calculated. Give an example. (APRIL/MAY 2010) (E)

11. Discuss all the asymptotic notations in detail. (APRIL/MAY 2012)(R)

12. Write an algorithm for finding maximum element of an array, perform best, worst and
average case complexity with appropriate order notations. (APRIL/MAY 2008) (R)

13. Write an algorithm to find mean and variance of an array perform best, worst and average
case complexity, defining the notations used for each type of analysis. (APRIL/MAY 2008)
(AN)

14. (i)Briefly explain the time complexity, space complexity estimation.(6) (MAY/JUNE 2013)
(ii) Write the linear search algorithm and analyze its time complexity.(10) (Nov/Dec 2016) (R)

15. (i) Find the time complexity and space complexity of the following problems. Factorial using
recursion and Compute nth Fibonacci number using Iterative statements. (C)

(ii) Solve the following recurrence relations: (NOV/DEC 2012) (A)

1). ( )

IIYEAR/IV SEMESTER

9
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

( )
2) { Where a and c are constants.

16. Solve the following inequalities are correct (MAY/JUNE 2013) (A)

(i)
(ii) n!=O( )
(iii)
(iv)

17. If you have to solve the searching problem for a list of n numbers, how can you take
advantage of the fact that the list is known to be sorted? Give separate answer for

(i) List represented as arrays


(ii) List represented as linked lists
Compare the time complexities involved in the analysis of both the algorithms.(MAY 2015)
(AN)

18. (i) Derive the worst case analysis of merge sort using suitable illustrations.(8)(MAY 2015)
(ii) Derive a loose bound on the following equation (8) (A)
F(x) =35x8 -22x7 +14x5 – 2x4 -4x2 +x-15

19. Give an algorithm to check whether all the Elements in a given array of n elements are
distinct. Find the worst case complexity of the same.(8) (MAY / JUNE 2016) (A)

20. Give the recursive algorithm which finds the number of binary digits in the binary
representation of a positive decimal integer. Find the recurrence relation and complexity. (MAY
/ JUNE 2016) (A)

21. State the general plan for analyzing the time efficiency of non-recursive algorithm and
explain with an example. (8) (Nov/Dec 2016) (AN)

22. Solve the following recurrence relation. (A)

 x(n)=x(n-1)+5 for n>1 x(1)=0


 x(n)=3x(n-1) for n>1 x(1)=4
 x(n)=x(n-1)+n for n>1 x(0)=0
 x(n)=x(n/2)+n for n>1 x(1)=1 (solve for n=2k )
 x(n)=x(n/3)+1 for n>1 x(1)=1 (solve for n=3 k ) (16) (Nov/Dec 2016)

22. Briefly explain the mathematical analysis of recursive and non-recursive algorithm. (8)
(Apr/May 2017) (R)
IIYEAR/IV SEMESTER

10
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

23. Discuss the steps in mathematical analysis for recursive algorithms. Do the same for finding
the factorial of the number. (NOV/DEC 2017)

24. Give the general plan for analyzing the time efficiency of recursive algorithm and use
recurrence to find number of moves Towers of Hanoi problem. (APR/MAY 18)

25. Consider the problem of finding the smallest and largest elements in an array of n numbers.
(APR/MAY 18)

(i) Design a presorting- based algorithm for solving this problem and determine its efficiency
class. (7)

(ii) Compare the efficiency of the three algorithms: (8)

(A) the brute force algorithm (B) this presorting based algorithm (C) the divide and conquer
algorithm.
26. (i)Prove that if g(n) is Ω(f(n)) then f(n) is O(g(n)). (5) (NOV/DEC 2018)

(ii) Discuss vrious methods used for mathematical analysis of recursive algorithms.(8)
(NOV/DEC 2018)

27. Write the asymptotic notations used for best case,average case and worst case analysi of
lgorithms. Writa an algorithm for finding maximum elements in an array. Give best,worst and
average case complexities. (NOV/DEC 2018)

28. (i) Solve the following recurrence relation: (APR/MAY 2019)

(1) T(n)=T(n/2)+1, where n=2k for all k> 0 (4)

(2) T(n)=T(n/3)+T(2n/3)+cn, where ‗c‘ is a constant and ‗n‘ is the input size.

(ii) Explains the steps involved in problem solving. (APR/MAY 2019)

29. a) i) consider the problem of counting, in a given text the number of substrings

that start with an a and end with a B. For example, there are four such

substrings in caBaaxBYa. Design a brute-force algorithm for this

problem and determine its efficiency class. (8)

i) ―The best-case analysis is not as important as the worst-case analysis of an

algorithm‖. Yes or No ? Justify your answer with the help of an example. (5) (APRIL/MAY
2021)

30. b) i) solve : T(n) = 2T(n/2) + n. (4)

IIYEAR/IV SEMESTER

11
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

ii) Explain the importance of asymptotic analysis for running time of an algorithm with an
example. (4)
iii) Write and explain recursive algorithm to find the factorial of any given number
n > = 0. Find the time complexity. (5) (APRIL/MAY 2021)

UN IT II
BRUTE FORCE AND DIVIDE-AND-CONQUER

Brute Force – Computing an – String Matching - Closest-Pair and Convex-Hull Problems -


Exhaustive Search - Travelling Salesman Problem - Knapsack Problem - Assignment
problem. Divide and Conquer Methodology – Binary Search – Merge sort – Quick sort –
Heap Sort - Multiplication of Large Integers – Closest-Pair and Convex - Hull Problems
PART A

1. Define Brute force Techniques?


Brute force is a straightforward approach to solving a problem, usually directly based on
the problem statement and definitions of the concepts involved.

2. Define Brute force String Matching Techniques?


String matching is something crucial for database development and text processing
software. The string-matching problem given a string of n characters called the text and a
string of m characters (m ≤ n) ca led the pattern, find a substring of the text that matches
the pattern.

3. List the strength and weakness of brute force algorithm.


Strengths
a. wide applicability,
b. simplicity
c. yields reasonable algorithms for some important problems
(e.g., matrix multiplication, sorting, searching, string matching)

Weaknesses
d. rarely yields efficient algorithms

e. some brute-force algorithms are unacceptably slow not as constructive as some


other design techniques

4. What is exhaustive search?


A brute force solution to a problem involving search for an element with a special property,
usually among combinatorial objects such as permutations, combinations, or subsets of a
set.

IIYEAR/IV SEMESTER

12
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF
IT

5. Give the general plan of exhaustive search. Method:

i. Generate a list of all potential solutions to the problem in a systematic manner


ii. Evaluate potential solutions one by one, disqualifying infeasible ones and, for an
optimization problem, keeping track of the best one found so far
iii. When search ends, announce the solution(s) found.

6. Define Quick Sort.


Quick sort is an algorithm of choice in many situations because it is not difficult to
implement, it is a good \"general purpose\" sort and it consumes relatively fewer resources
during execution.

7. List out the Disadvantages in Quick Sort


i. It is recursive. Especially if recursion is not available, the implementation is extremely
complicated.
ii. It requires quadratic (i.e., n2) time in the worst-case.
iii. It is fragile i.e., a simple mistake in the implementation can go unnoticed and cause it to
perform badly.

8. What is the difference between quicksort and mergesort?


Both quicksort and mergesort use the divide-and-conquer technique in which the given
array is partitioned into subarrays and solved. The difference lies in the technique that the
arrays are partitioned. For mergesort the arrays are partitioned according to their position
and in quicksort they are partitioned according to the element values.

9. Define Heap sort?


Heap Sort is one of the best sorting methods being in-place and with no quadratic worst-
case running time. Heap sort involves building a Heap data structure from the given array
and then utilizing the Heap to sort the array.
10. What are the properties of heap structure?

The special heap properties given below:

Shape Property: Heap data structure is always a Complete Binary Tree, which means all
levels of the tree are fully filled.

IIYEAR/IV SEMESTER

13
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF
IT

Heap Property: All nodes are either greater than or equal to or less than or equal to
each of its children. If the parent nodes are greater than their child nodes, heap is called a
Max-Heap, and if the parent nodes are smaller than their child nodes, heap is called Min-
Heap.

11. What are the two basic parts of Heap sort ?

 Creating a Heap of the unsorted list/array.


 Then a sorted array is created by repeatedly removing the largest/smallest element
from the heap, and inserting it into the array. The heap is reconstructed after each
removal.

12. What is the Complexity Analysis of Heap Sort?

Worst Case Time Complexity: O(n*log n)

Best Case Time Complexity: O(n*log n)

Average Time Complexity: O(n*log n)

Space Complexity : O(1)

13. What are the advantages of Heap sort ?

 Heap sort is not a Stable sort, and requires a constant space for sorting a list.
 Heap Sort is very fast and is widely used for sorting.

IIYEAR/IV SEMESTER

14
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF
IT

14. Give the general plan for divide -and-conquer algorithms. (APRIL/MAY 2008)
(NOV/DEC 2008) (MAY/JUNE 2016) (R) (Nov 17)
The general plan is as follows.
 A problems instance is divided into several smaller instances of the same problem,
ideally about the same size.
 The smaller instances are solved, typically recursively.
 If necessary the solutions obtained are combined to get the solution of the original
problem.

15. List the advantages of Divide and Conquer Algorithm.


Solving difficult problems, Algorithm efficiency, Parallelism, Memory access, Round off
control.

16. Define of feasibility.


A feasible set (of candidates) is promising if it can be extended to produce not merely a
solution, but an optimal solution to the problem.

17. Give the recurrence relation of divide -and-conquer? (R)


The recurrence relation is
 g (n)

T(n) = t(n1)  t(n2)  .....  t(nk )  f (n) g(n)

18. What is binary search? (R)


Binary search is a remarkably efficient algorithm for searching in a sorted
array. It works by comparing a search key K with the arrays middle element A[m]. if they
match the algorithm stops; otherwise the same operation is repeated recursively for the first
half of the array if K < A[m] and the second half if K > A[m].
a. A[0]………A[m-1] A[m] A[m+1]………A[n-1]

19. Give computing time for Binary search?(APRIL/MAY 2012) (E)


a. In conclusion we are now able completely describe the computing time of binary
search by giving formulas that describe the best, average and worst cases.
Successful searches
Best-(1) average-(logn) worst -(Logn)
unsuccessful searches best, average, worst- (logn)

20. Write the algorithm for Iterative binary search? (A)


Algorithm BinSearch(a,n,x)
//Given an array a[1:n] of elements in nondecreasing
// order, n>0, determine whether x is present
{
low : = 1;
high : = n;
while (low < high) do
{
IIYEAR/IV SEMESTER

15
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF
IT

mid : = [(low+high)/2];

IIYEAR/IV SEMESTER

16
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

-1;

else return mid;


}
return 0;
}
21. Define merge sort. (R)
a. Mergesort sorts a given array A[0..n-1] by dividing it into two halves a[0..(n/2)-1]
and A[n/2..n-1] sorting each of them recursively and then merging the twosmaller
sorted arrays into a single sorted one.

22. List the Steps in Merge Sort

Divide Step: If given array A has zero or one element, return S; it is already sorted.
Otherwise, divide A into two arrays, A1 and A2, each containing about half of the elements
of A.

Recursion Step: Recursively sort array A1 and A2.

Conquer Step: Combine the elements back in A by merging the sorted arrays A1 and A2
into a sorted sequence

23. List out Disadvantages of Divide and Conquer Algorithm


Conceptual difficulty
Recursion overhead
Repeated subproblems

24. Define Quick Sort.


Quick sort is an algorithm of choice in many situations because it is not difficult to
implement, it is a good \"general purpose\" sort and it consumes relatively fewer resources
during execution.

25. List out the Advantages in Quick Sort


 It is in-place since it uses only a small auxiliary stack.
 It requires only n log(n) time to sort n items.
 It has an extremely short inner loop
This algorithm has been subjected to a thorough mathematical analysis, a very precise
statement can be made about performance issues.

26. Describe the recurrence relation of merge sort? (R)


a. If the time for the merging operation is proportional to n, then the computing time
of merge sort is described by the recurrence relation
T(n)= a
2T(n/2)+n n = 1, a constant

IIYEAR/IV SEMESTER

17
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

27. Define Selection Sort? (R)


We start selection sort by scanning the entire given list to find its smallest element and
exchange it with the first element, putting the smallest element in its final position in the
sorted list. Then we scan the list, starting with the second element ,to find the smallest
among the last n − 1 elements and exchange it with the second element, putting the
second smallest element in its final position.

28. Define Bubble Sort? (R)


Another brute-force application to the sorting problem is to compare adjacentelements of
the list and exchange them if they are out of order. By doing itrepeatedly, we end up
―bubbling up‖ the largest element to the last position onthe list. The next pass bubbles up
the second largest element, and so on, untilafter n − 1 passes the list is sorted.

29. Define Closest-Pair Problem? (MAY/JUNE 2016) (Apr/May 2017) (R)


The closest-pair problem calls for finding the two closest points in a set of n points. It is
the simplest of a variety of problems in computational geometry thatdeals with proximity
of points in the plane or higher-dimensional spaces. Pointsin question can represent such
physical objects as airplanes or post offices as wellas database records, statistical
samples, DNA sequences, and so on.

30. Write the Pseudo code for computes the distance between the two closest points?
(Nov/Dec 2016) (A)
//Finds distance between two closest points in the plane by brute force
//Input: A list P of n (n ≥ 2) points p1(x1, y1), . . . ,pn(xn, yn)
//Output: The distance between the closest pair of points
d←∞
fori ←1 to n − 1 do
forj ←i + 1 to ndo
d←min(d, sqrt((xi− xj )2 + (yi− yj )2 )) //sqrt is square root
returnd

31. Define Convex-Hull Problem? (R)


The convex hull of a set S of points is the smallest convex set containing S. (The ―sma lest‖
requirement means that the convex hull of S must be a subset of any convex set containing S.)

32. Define Convex Set? (R)


A set of points (finite or infinite) in the plane is called convex if for any two pointsp and q in
the set, the entire line segment with the endpoints at p and q belongs to the set.

33. Define Exhaustive search? (R) (Apr 18)


Exhaustive search is simply a brute-force approach to combinatorial problems.It suggests
generating each and every element of the problem domain, selectingthose of them that satisfy
all the constraints, and then finding a desiredelement (e.g., the one that optimizes some
objective function). Note that althoughthe idea of exhaustive search is quite straightforward, its
implementation typicallyrequires an algorithm for generating certain combinatorial objects.

IIYEAR/IV SEMESTER

18
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

34. Define Traveling Salesman Problem? (R)


The traveling salesman problem (TSP) has been intriguing researchers for the last 150 years by
its seemingly simple formulation, important applications, and interesting connections to other
combinatorial problems. In layman‘s terms, the problem asks to find the shortest tour through a
given set of n cities that visits each city exactly once before returning to the city where it.

35. Design a brute -force algorithm for computing the value of a polynomial p(x)=a nx n +an -
n- 1
1x +-----+a1 x----a0 at a given point x0 and determine its worst case efficiency
class.(MAY2015) (C)
Number of multiplications needed in the worst case is
T(n) = n + n-1 + n-2 + … + 3 + 2 + 1
= n (n + 1)/2
=n2 /2 + n/2
This is an exact formula for the maximum number of multiplications. In general though, analyses
yield upper bounds rather than exact formulae. We say that the number of multiplications is on
the order of n2 , or O(n2 ).

36. Derive the complexity of Binary search algorithm. (MAY 2015) (Nov/Dec 2016) (R)
a. Cworst (n)=C worst ([n/2])+1 for n1, C worst (1)=1
b. C worst (2k )=k+1=log2 n+1
c. Cworst (n)=[log2 n]+1=[log2 (n+1)]
d. C worst (n)=[log2 n]+1=[log2 2i]+1=[log2 2+log2 i]+1
i. = (1+[log2 i])+1=[log2 i]+2
e. Cavg(n) log2 n.

37. Write the advantage of insertion sort? (NOV/DEC 2017)


1.Simple implementation
2.Efficient for small data sets
3.Adaptive
4.More efficient in practice than most other simple quadratic, i.e. O(n2) algorithms such as
Selection sort or bubble sort; the best case (nearly sorted input) is O(n)
5.Stable - does not change the relative order of elements with equal keys

38. List out the 4 steps in Strassen’s Method?


Divide the input matrices A and B into n/2 * n/2 submatrices, as in equation (1).

Using Θ(n2) scalar additions and subtractions, compute 14 n/2 * n/2 matrices A1, B1, A2,
B2, …, A7, B7.

3.. Recursively compute the seven matrix products Pi =AiBi for i =1, 2, 7.

Compute the desired submatrices r, s, t, u of the result matrix C by adding and/or


subtracting various combinations of the Pi matrices, using only Θ(n2) scalar additions and
subtractions.

IIYEAR/IV SEMESTER

19
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

39. State Master’s theorem. (APR/MAY 18)


If f(n) θ(nd) where d ³ 0 in recurrence equation T(n) = aT(n/b)+f(n), then
θ (nd) if a<bd T(n) θ (ndlog n) if a=bd
θ (nlog ba) if a>bd

The efficiency analysis of many divide-and-conquer algorithms is greatly simplified by the use
of Master theorem.

40. List out the Disadvantages in Quick Sort


 It is recursive. Especially if recursion is not available, the implementation is extremely
complicated.
 It requires quadratic (i.e., n2) time in the worst-case.
 It is fragile i.e., a simple mistake in the implementation can go unnoticed and cause it to
perform badly.

41.What are the differences between dynamic programming and divide and conquer
approaches? (NOV/DEC 2018)
Divide and Conquer
Divide and Conquer works by dividing the problem into sub-problems, conquer each sub-
problem recursively and combine these solutions.
Dynamic Programming
Dynamic Programming is a technique for solving problems with overlapping subproblems. Each
sub-problem is solved only once and the result of each sub-problem is stored in a table (
generally implemented as an array or a hash table) for future references. These sub-solutions
may be used to obtain the original solution and the technique of storing the sub-problem
solutions is known as memoization.

42.Give an example of Hamiltonian circuit? (NOV/DEC 2018)


The Hamiltonian is defined as a cycle that passes through all the vertices of the graph exactly
once. It is named after the Irish mathematician Sir William Rowan Hamilton (1805-1865).It is a
sequence of n+1 adjacentverticesvi0, vi1… vin-1, vi0 where the first vertex of the sequence is
same as the last one while all the other n-1 vertices are distinct.

43.Write the brute force algorithm to string matching. (APR/MAY 2019)


Algorithm BruteForceStringMatch(T[0...n-1], P[0...m-1])
for i ← 0 to n-m do
j←0
while j < m and P[j] = T[i+j] do
j++
if j = m then return i
return -1

44.What is the time and space complexity of Merge sort? (APR/MAY 2019)
Time complexity = θ(n log n)
Space complexity = n+log2 n
=θ(n)

IIYEAR/IV SEMESTER

20
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

45. Write the general divide and conquer approach to solve a problem. (APR/MAY 2021)
Divide-and-conquer algorithms work according to the following general plan:
1. A problem is divided into several subproblems of the same type, ideally of about equal
size.
2. The subproblems are solved (typically recursively, though sometimes a different
algorithm is employed, especially when subproblems become small enough).
3. If necessary, the solutions to the subproblems are combined to get a solution to the
original problem.

PART-B

1. Define divide and conquer to apply the technique in binary search algorithm and to analysis it.
(APR/MAY 2006) (APR/MAY 2017) (R)

2. Explain in detail in merge sort give an example (APR/MAY 2008) (MAY 2016). (R)

3. What is divide and conquer strategy and explain the binary search with suitable example
problem.(NOV/DEC 2011) (R)

4. Distinguish between Quick sort and Merge sort, and arrange the following numbers in
increasing order using merge sort. (18, 29, 68, 32, 43, 37, 87, 24, 47, 50) (NOV/DEC 2011)
(MAY/JUNE 2013). (A)

5. Trace the steps of Mergesort algorithm for the elements 122,25,70,175,89,90,95,102,123 and
also compute its time complexity.(NOV/DEC 2012) (A) (Nov 17) (Apr 18)

6. Explain brute-force approach. What are the advantages and disadvantages of this approach? ®

7. Write an algorithm to perform binary search on a sorted list of elements. Analyze the
algorithm for the best case, average case and worst case.(APR/MAY 2011). (AN)

8. Using the divide and conquer approach to find the maximum and minimum in a set of ‗n‘
elements. Also find the recurrence relation for the number of elements compared and solve the
same.(APR/MAY 2011). (A)

9. Explain Closest-pair and Convex-Hull problems by Brute Force? ®

10. Explain Exhaustive Search? ®

11. Write an efficient and exhaustive search algorithm for the travelling salesman problem? ®

12. Trace maximum and minimum (using divide and conquer) algorithm for the following set of
numbers. 20, 35, 18, 8, 14, 41, 3, 39,-20. (A)

IIYEAR/IV SEMESTER

21
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

13. Write a pseudo code using divide and conquer technique for finding the position of the
largest element in an array of N numbers. (A)

14. Sort the following set of elements using merge sort: 12, 24, 8, 71, 4, 23, 6, 89, and 56. (A)

15. Explain in detail quick sorting method. Provide a complete analysis of quick sort.
(APR/MAY 2008) (Nov/Dec 2016) (APR/MAY 2017) (AN)

16. Explain in detail the merge sort. Illustrate the algorithm with a numeric example. Provide
complete analysis of the same. (APR/MAY 2008) (AN)

17. (i) Solve the following using Brute force algorithm: (MAY 2015) (APR/MAY 2017)
Find whether the given string follows the special pattern and return 0 or 1 accordingly.

Examples:
1. Pattern: ―abba‖, input: ―redblueredblue‘ should return 1.
2. Pattern: ―aaaa‖, input: ―asdasdasdasd‖ should return 1.
3. attern: ―aabb‖, input: ―xyzabcxzyabc‖ should return 0.
(ii) Explain the convex hull problem and the solution involved behind it. (A)

18. A pair contains two numbers and its second number is on the right side of the first one in an
array. The difference of a pair is the minus result while subtracting the second number from the
first one. Implement a function which gets the maximal difference of all pairs in an array (using
divide and conquer method). (MAY/JUNE 2015) ®
19. Explain the method used for performing Multiplication of two large integers. Explain how
divide and conquer method can be used to solve the same. (MAY/JUNE 2016). (R)

20. Find all the solution to the traveling salesman problem (cities and distance shown below) by
exhaustive search. Give the optimal solutions. (MAY/JUNE 2016) (R)

21. There are 4 people who need to be assigned to execute 4 jobs (one person per job) and the
problem is to find the assignment with the minimum total cost. The assignment costs is given
below, solve the assignment problem by exhaustive search. (16) (NOV/DEC 2016) (A)

Job 1 Job 2 Job 3 Job 4


Person 1 9 2 7 8
Person 2 6 4 3 7
Person 3 5 8 1 8
Person 4 7 6 9 4
22. Explain the Brute force method to find the two closest points in a set of n points in k-
dimensional space? (NOV/DEC 2017)
23. Explain the working of Strassen‘s Matrix Multiplication with the help of divide and conquer
method. (APR/MAY 18)

IIYEAR/IV SEMESTER

22
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF
IT

24. Explain the concept of heap sort with example?


25.Solve travelling salesman problem using brute force approach for the given example. How the
solution can be obtained using branch and bound method?(13)(NOV/DEC 2018)

26. Write the algorithm for quick sort. Provide a complete analysis of quick sort for the given set
of numbers 12,33,23,43,44,55,64,77 and 76. (13)(NOV/DEC 2018)
27. What is the convex hull problem? Explain the brute force approach to solve convex-hull with
an example. Derive the time complexity. (2+7+4) (APR/MAY 2019)
28.Write the quick sort algorithm and explain it with an example. Derive the worst case and
average case time complexity. (5+4+4) (APR/MAY 2019)
29. a) i) Let x 1 < x2 < ... < x be real numbers representing coordinates of n villages
located along a straight road. a post office needs to be built in one of these
villages. Design an efficient algorithm to find the post-office location
minimizing the average distance between the villages and the post-office. (8)
ii) Explain how exhaustive search can be applied to the sorting problem and
determine the efficiency class of such an algorithm. (5) (APRIL/MAY 2021)
30. b) i) Write an algorithm using divide and conquer to search an element in a
list of numbers. if the number is not present, the algorithm returns the
closest number of the searches number. (8)
IIYEAR/IV SEMESTER

23
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF
IT

i) What is strassen‘s matrix multiplication and explain how it is solves the


problem using divide and conquer technique. (5) (APRIL/MAY 2021)

IIYEAR/IV SEMESTER

24
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

UNIT – III
DYNAM IC PROGRAM M ING AND GREEDY TECHNIQUE
Dynamic programming – Principle of optimality - Coin changing problem, Computing a
Binomial Coefficient – Floyd‗s algorithm – Multi stage graph - Optimal Binary Search Trees –
Knapsack Problem and Memory functions. Greedy Technique – Container loading problem -
Prim‗s algorithm and Kruskal's Algorithm – 0/1 Knapsack problem, Optimal Merge pattern -
Huffman Trees.

PART –A
1. Define dynamic programming. (APR/MAY 2017) (R)
Dynamic programming is an algorithm design method that can be used when asolution to
the problem is viewed as the result of sequence of decisions.

2. What are the features of dynamic programming? (R)


 Optimal solutions to sub problems are retained so as to avoid re-computing their values.
 Decision sequences containing subsequences that are sub optimal are not considered.
 It definitely gives the optimal solution always.

3.What are the drawbacks of dynamic programming? (R)


 Time and space requirements are high, since storage is needed for all level.
 Optimality should be checked at all levels.

4. Write the general procedure of dynamic programming. (APR/MAY 2017) (R)


The development of dynamic programming algorithm can be broken into a
sequence of 4 steps.
1. Characterize the structure of an optimal solution.
2. Recursively defines the value of the optimal solution.
3. Compute the value of an optimal solution in the bottom-up fashion.
4. Construct an optimal solution from the computed information.

5. Write the difference between the Greedy method and Dynamic


programming.(APRIL/MAY 2011)(NOV/DEC 2012) (AN)

1.Only one sequence of decision is 1.Many number of decisions


generated. are
2.It does not guarantee to give an 2.It definitely gives an
optimal solution always. optimal

IIYEAR/IV SEMESTER

25
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

6. Give the Floyd’s algorithm (C) (Nov 17)


ALGORITHM Floyd(W[1..n,1..n])
//Implements Floyd‘s algorithm for the all-pair shortest–path problem
//Input The weight matrix W of a graph
//Output The distance matrix of the shortest paths‘ lengths
D <- W
for k = 1 to n do
for i =1 to n do
for j =1 to n do
D[I,j] = min{D[I,j], D[I,k] + D[k,j]

7. Give the time complexity and space complexity of traveling salesperson problem. (AN)
Time complexity is O (n2 2n ).
Space complexity is O (n 2n ).

8. Write some applications of traveling salesperson problem. (R)


Routing a postal van to pick up mail from boxes located at n different sites. Using a robot
arm to tighten the nuts on some piece of machinery on an assembly line. Production environment
in which several commodities are manufactured on the sameset of machines.

9. Write about traveling salesperson problem. (NOV/DEC 2011) (R)


Let g = (V, E) be a directed. The tour of G is a directed simple cycle that includes every vertex
in V. The cost of a tour is the sum of the cost of the edges on the tour. The traveling salesperson
problem to find a tour of minimum cost.

10. Define multistage graph. (NOV/DEC 2011)(NOV/DEC 2012) (R)


A multistage graph G=(V,E) is a directed graph in which the vertices are partitioned into k≥2
disjoint sets Vi,1≤i≤k.
 If <u,v> is an edge in E, then u€ Vi and v € Vi+1 for some i, 1≤i≤k.
 Let s and t, respectively be the vertices in v1 and vk . The vertex s is the source, and t the
sink.
 Let c(i,j) be the cost of edge <i,j>.
 The cost of a path from s to t is the sum of the costs of the edges on the path.
 The multistage graph problem is to find a minimum-cost path from s to t.

12. Define optimal finish time. (R)


Optimal finish time scheduling for a given set of tasks is a non-preemptive schedule S for
which F (S) is minimum over all non-preemptive schedules S.

IIYEAR/IV SEMESTER

26
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

13. Define preemptive optimal finish time. (R)


 Preemptive optimal finish time scheduling for a given set of tasks is a preemptive
scheduleS for which F (S) is minimum over all preemptive schedules S.
 The finish time fi (S) of job i is the time at which all tasks of job i have been completed
inscheduleS.The finish time F(S) of schedule S is given by
o F(S)=max{ fi (S)} 1<i<n

14. Define the principle of optimality. (APR/M AY 2012) (NOV/DEC 2016) (R) (Nov 17)
It states that in an optimal sequence of decisions, each sub sequence must be optimal.
Touse dynamic programming the problem must observe the principle of optimality thatwhatever
the initial state is, remaining decisions must be optimal with regard the statefollowing from the
first decision.

15. Define 0/1 knapsack problem. (NOV/DEC 2008) (NOV/DEC 2012) (R)
The solution to the knapsack problem can be viewed as a result of sequence of decisions.
We have to decide the value of xi. xi is restricted to have the value 0 or 1 and by using the
function knap(l, j, y) we can represent the problem as maximum Σpi xi subject to Σwi xi < y
where l -iteration, j - number of objects, y – capacity.

16. What is the formula to calculate optimal solution in 0/1 knapsack problem? (R)
The formula to calculate optimal solution is g(m)=max{g1, g1(m-w1)+p1}.

17. What is the difference between dynamic programming and greed


algorithm?(APRIL/MAY 2012) (AN)
S.No. GREEDY ALGORITHM DYNAMIC PROGRAMMING
1. 1. GA computes the solution in bottom up DA computes its solution by making
technique. It computes the solution from its choices in a serial fashion (never
smaller sub-routines and tries many look back irrevocable).
possibilities and choices before it arrives at
the optimal set of choices.
2. It does not use the principle of optimality, i.e. It uses the principle of optimality.
there is no test by which one can tell GA will
lead to an optimal solution.

18. Define Optimal Binary Search Trees? (R)


A binary search tree is one of the most important data structures in computer science.
One of its principal applications is to implement a dictionary, a set of elements with the
operations of searching, insertion, and deletion. If probabilities of searching for elements of a set
are known e.g., from accumulated data about past searches - it is natural to pose a question about

IIYEAR/IV SEMESTER

27
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

an optimal binary search tree for which the average number of comparisons in a search is the
smallest possible.

19. Define Memory Functions? (R)


The memory function technique seeks to combine the strengths of the topdownand
bottom-up approaches to solving problems with overlappingsubproblems. It does this by solving,
in the top-down fashion but onlyonce, just the necessary subproblems of a given problem and
recording theirsolutions in a table.
20. Define Prims Algorithm. (R)
Prim‘s algorithm constructs a minimum spanning tree through a sequenceof expanding
subtrees. The initial subtree in such a sequence consists of a singlevertex selected arbitrarily
from the set V of the graph‘s vertices. On each iteration,the algorithm expands the current tree in
the greedy manner by simply attaching toit the nearest vertex not in that tree.

21. Write down the optimization technique used for Warshalls algorithm. State the rules
and assumptions which are implied behind that. (MAY 2015) (R)

Warshalls algorithm constructs the transitive closure of given digraph with n vertices
through a series of n-by-n Boolean matrices. The computations in warshalls algorithm are given
by following sequences,
R(0),…,R(k-1) ,…,R(k),…,R(n)
Rules:
1.Start with computation of R(0). In R(0) any path with intermediate veritices is not allowed. That
means only direct edges towards the vertices are considered. In other words the path length of
one edge is allowed in R(0). Thus R(0) is adjacency matrix for the digraph.
2. Construct R(1) in which first vertex is used as intermediate vertex and a path length of two
edge is allowed. Note that R(1) is build using R(0)which is already computed.
3. Go on building R(k) by adding one intermediate vertex each time and with more path length.
Each R(k) has to be built from R(k-1)
4. The last matrix in this series is R(1), in this R(n) all the n vertices are used as intermediate
vertices. And the R(n) which is obtained is nothing but the transitive closure of given digraph.

22. List out the memory functions used under Dynamic programming. (MAY 2015) (R)
Memory functions solve in a top-down manner only sub problems that are necessary.
Memory functions are an improvement of dynamic programming because they only solve sub
problems that are necessary and do it only once. However they require more because it makes
recursive calls which require additional memory.
 Greedy Algorithm
 Branch and Bound
 Genetic Algorithm

IIYEAR/IV SEMESTER

28
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

23. Define the single source shortest path problem. (MAY\JUNE 2016) (R)
Dijkstra‘s algorithm solves the single source shortest path problem of finding shortest
paths from a given vertex( the source), to all the other vertices of a weighted graph or digraph.
Dijkstra‘s algorithm provides a correct solution for a graph with non-negative weights.

24. How to calculate the efficiency of dijkstra’s algorithm. (NOV/DEC 16) (R)
The time efficiency depends on the data structure used for implementing the
priority queue and for representing the input graph. It is in θ (|V|)2 for graphs represented by
their weight matrix and the priority queue implemented as an unordered array. For graphs
represented by their adjacency linked lists and the priority queue implemented as a min_heap it
is in O(|E|log|V|).

25. State the general principle of greedy algorithm. (NOV/DEC 16) (R)
A greedy algorithm is an algorithmic paradigm that follows the problem solving
heuristic of making the locally optimal choice at each stage with the hope of finding a global
optimum.

26. Define transitive closure of a directed graph. (APR/MAY 2018)


The transitive closure of a directed graph with n vertices can be defined as the ―n-by-n‖
Boolean matrix T={tij} in which,the element in the ith row (1<i<n) and the jth column (1<j<n)
exists a non-trival directed path from the Ith vertex to the jth vertex,otherwise tij is 0.

27.Define Container Loading Problem ?


A large ship is to be loaded with cargo. The cargo is containerized, and all containers
are the same size. Different containers may have different weights. Let wi be the
weight of the ith container, 1<=i<=n. _1The cargo capacity of the ship is c. We wish
to load the ship with the maximum number of containers.
Formulation of the problem :
Variables : is set to if the container is not to be loaded and in the other case.
Constraints :

28 .Define Optimization function ?


Every set of s that satisfies the constraints is a feasible solution.
Every feasible solution that maximizes is an optimal solution.

29.Define Greedy Methodology?


Greedy algorithms are simple and straightforward.
They are shortsighted in their approach
A greedy algorithm is similar to a dynamic programming algorithm, but the difference is that

can be made of what looks best for the moment.

IIYEAR/IV SEMESTER

29
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF
IT

30.Define an optimization problem?


Given a problem instance, a set of constraints and an objective function.
Find a feasible solution for the given instance for which the objective function has an optimal
value.
Either maximum or minimum depending on the problem being solved.A feasible solution that
does this is called optimal solution.

31. Write all the Greedy Properties?


It consists of two property,
1. "greedy-choice property" ->It says that a globally optimal solution can be arrived at by making
a locally optimal choice.
2. "optimal substructure" ->A problem exhibits optimal substructure if an optimal solution to the
problem contains optimal solutions to the sub-problems.
are two ingredients in the problem that lend to a greedy strategy.

32.State feasible and consrtraint ?


Feasible: A feasible solution satisfies the problem‘s constraints
Constraints: The constraints specify the limitations on the required solutions

33.Write the Pseudo-code for Greedy Algorithm


Algorithm Greedy (a,n)
//a[1:n]contains the n inputs.
{
solution:=0;//initialize the solution.
for i:=1 to n do
{
x:=Select(a);
if Feasible( solution, x) then
solution:=Union(solution,x);
}
return solution

34. Comment on coin change problem:


Make a change of a given amount using the smallest possible number of coins.
Solution:
The coin is selected using greedy criterion: at each stage increases the total amount of change
constructed as much as possible.
To assure feasibility i.e., the change given exactly equals the desired amount of the solution

35.Explain in about Greedy Algorithm problem of "Making Change".


It works by making the decision that seems most promising at any moment; it never reconsiders
this decision, whatever situation may arise later.
As an example consider the problem of "Making Change".
Coins available are:
– 100 cents
– 25 cents
IIYEAR/IV SEMESTER

30
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

– 10 cents
– 5 cents
– 1 cent

Problem:
Make a change of a given amount using the smallest possible number of coins.

Solution:
The coin is selected using greedy criterion: at each stage increases the total amount of change
constructed as much as possible.
To assure feasibility i.e., the change given exactly equals the desired amount of the solution

36. what is the Time complexity of loading container?


The overall Time complexity of loading container is O(n log n)

37.Write the Algorithm Container Loading problem?


Algorithm Container Loadin (c,capacity,number of
containers,x )
//greedy algorithm for container loading
//set x[i]=1 iff container c[i],i>=1 is loaded.
{
//sort into increasing order of weight
Sort(c,number of Containers);
n:=number of Containers;
//initialize x
for i:=1 to n do
x[i]:=0;
//select containers in order of weight
i :=1;
While(i<=n&& c[i].weight<=capacity)
{
//enough capacity for container c[i].id
X[c[i].id]:=1;
Capacity-=c[i].weight;//remaining capacity
i++;
}
}

38.Compare With Dynamic Programming ?


Greedy And Dynamic Programming are methods for solving optimization problems.
Greedy algorithms are usually more efficient than DP solutions. However, often you need to use
dynamic programming since the optimal solution cannot be guaranteed by a greedy algorithm.
DP provides efficient solutions for some problems for which a brute force approach would be
very slow.

IIYEAR/IV SEMESTER

31
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

39. Differentiate PROS AND CONS


PROS:
 They are easier to implement,
 They require much less computing resources,
 They are much faster to execute.
 Greedy algorithms are used to solve optimization problems
CONS:
 Their only disadvantage being that they not always reach the
global optimum solution;
 on the other hand, even when the global optimum solution is not reached, most of the
times the reached sub-optimal solution is a very good solution

40. Comment on Change making problem?

A child buys a candy bar at less than one buck and gives a $1 bill to the cashier, who wants to
make a change using the smallest number of coins. The cashier constructs the change in stages,
in each of which a coin is added to the change.
The greedy criterion is as follows: At each stage, increase the total amount as much as possible.
A feasible solution is one such that in no stage the amount paid out so far exceeds the desired
change.

For example, if the desired change is 67 cents.The first two stages will add in two quarters.

The next one adds a dime, and following one will add a nickel, and the last two will finish off
with two pennies.

41. Comment on merge pattern?

Merge a set of sorted files of different length into a single sorted file. We need to find an
optimal solution, where the resultant file will be generated in minimum time.

If the number of sorted files are given, there are many ways to merge them into a single sorted
file. This merge can be performed pair wise. Hence, this type of merging is called as 2-way
merge patterns.

42.Define multistage graphs. Give an example. (NOV/DEC 2018)

A multistage graph G = (V, E) is a directed graph where vertices are partitioned


into k (where k > 1) number of disjoint subsets S = {s1,s2,…,sk} such that edge (u, v) is in E,
then u Є si and v Є s1 + 1 for some subsets in the partition and |s1| = |sk| = 1.
The vertex s Є s1 is called the source and the vertex t Є sk is called sink.

IIYEAR/IV SEMESTER

32
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

43.How dynamic programming is used to solve Knapsack problem.(NOV/D EC 2018)

Dynamic Programming is an algorithm design technique that involves identifying subproblems


within the overall problem and solving them starting with the smallest one. Results of smaller
subproblems are memoized, or stored for later use by the subsequent larger subproblems.

44.State the principle of optimality. (APR/MAY 2019)

In an optimal sequence of decisions or choices, each subsequence must also be optimal. When it
is not possible to apply the principle of optimality it is almost impossible to obtain the solution
using the dynamic programming approach.
Example: Finding of shortest path in a given graph uses the principle of optimality.

45.What is the constraint for binary search tree insertion? (APR/MAY 2019)

T he root of a binary search tree and values to be inserted into the tree. Insert the values into their
appropriate position in the binary search tree and return the root of the updated binary tree.
Input Format:
Node * insert (Node * root ,int data) {

}
Constraints

No. of nodes in the tree 500

46. What is meant by optimal substructure property of a dynamic programming problem.


(APR/MAY 2021)
Dynamic Programming Binomial Coefficients Dynamic Programming was invented by Richard
Bellman, 1950. It is a very general technique for solving optimization problems. Dynamic
Programming requires: 1. Problem divided into overlapping sub-problems 2. Sub-problem can be
represented by a table 3. Principle of optimality, recursive relation between smaller and larger
problems.
IIYEAR/IV SEMESTER

33
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

47. Write the control abstraction for greedy method. (APR/MAY 2021)

Control Abstraction for Greedy algorithm

Algorithm Greedy(A : set; n : integer){

MakeEmpty(solution);

f or(i = 2;i <= n;i + +){

x = Select(A);

if F easible(solution, x) then

solution = Union(solution, {x})

return solution

The function Greedy describes the essential way that a greedy algorithm will look, once a
particular problem is chosen and the functions Select, F easible and Union are properly
implemented.

PART –B
1. (i)Write an algorithm to construct the optimal binary search tree (or) Discuss the algorithm for
finding a minimum cost binary search trees.(8)

(ii) Explain how dynamic programming is applied to solve travelling salesperson problem.
(APR/MAY 2010)(NOV/DEC 2012)(8) (R)

2. Describe traveling sales man problem and how to solve using dynamic programming
(may/2006). (APR/MAY2009) (APR/MAY 2012) (R)
3. Write an algorithm for all pairs shortest path algorithm and what are the time and space
complexity of the algorithm. (APIRL/MAY2009) (APRIL/MAY 2012) (R)
4. To consider the following instance of the knapsack problem n=6,(p1,p2,p3,p4,p5,p6)
=(w1,w2,w3,w4,w5,w6)=(100,50,20,10,10,7,3) m=165 To use dynamic programming
technique to solve the problem. (A)

IIYEAR/IV SEMESTER

34
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

5. Explain Floyd algorithm with example. Write down and explain the algorithm to solve all
pairs shortest paths problem. (APRIL/MAY 2010)(MAY/JUNE 2013). (R)
6. Using Dynamic approach programming, solve the following graph using the backward
approach.(APRIL/MAY2011) (A)

7. Write dynamic programming solution for the travelling salesperson problem for the network
with the cost adjacency matrix (E)

0 10 15 30
4 0 9 11
5 13 0 10
7 7 8 0
8. Describe binary search tree with three traversal patterns? Give suitable example with neat
diagram for all three traversal of binary search? (R)
9. With a suitable example, explain all-pair shortest paths problem. (R)
10. How is dynamic programming applied to solve the travelling salesperson problem? Explain
in detail with an example? (R)

11. (i) Given the mobile numeric key pad. You can only press buttons that are up , left, right or
down to the first number pressed to obtain the subsequent numbers. You are not allowed to
press bottom row corner buttons (ie * and #). Given a number N, how many key strokes will
be involved to press the given number. What is the length of it? Which dynamic
programming technique could be used to find solution for this? Explain each step with the
help of a pseudo code and derive its time complexity. (12) (MAY 2015) (AN)

(ii) How do you construct a minimum spanning tree using Kruskals algorithm? Explain?(4)
(MAY 2015) (R)

12. (i) Let A ={l/119,m/96,c/247,g/283,h/72,f/77,k/92,j/19} be the letters and its frequency of


distribution in a text file. Compute a suitable Huffman coding to compress the data
effectively. (8) (MAY 2015)
(ii) Write an algorithm to construct the optimal binary search tree given the roots r(i,j)
,0≤i≤j≤n. Also prove that this could be performed in time O(n). (8) (MAY 2015) (AN)
IIYEAR/IV SEMESTER

35
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

13. Discuss about the algorithm and pseudocode to find the Minimum Spanning Tree using
Prim‘s Algorithm. Find the Minimum Spanning Tree for the graph. Discuss about the
efficiency of the algorithm.(MAY\JUNE 2016) (C) (Apr 18)

14. Solve the all-Pairs shortest-path problem for the diagraph with the following weight matrix:

(NOV/DEC 2016) (A)

15. Apply Kruskal‘s algorithm to find a minimum spanning tree of the following graph.

(NOV/DEC 2016) (A)

16. Solve the following instance of 0/1, knapsack problem gives the knapsack capacity in W -5
using dynamic programming and explain it. (APR/AMY 2017) (A)

Items Weight Value


1 4 10
2 3 20
3 2 15
4 5 25

17. Write the Huffman‘s Algorithm. Construct the Huffman‘s tree for the following data and
obtain its Huffman‘s Code. (APR/AMY 2017) (A)

Characters A B C D E _
Probability 0.5 0.35 0.5 0.1 0.4 0.2
18. Explain the working of merge sort algorithm with an example? (R) (NOV/DEC 2017)
19. Explain the Dijkstra‘s shortest path algorithm and its efficiency.( R) (NOV/DEC 2017)
20. Find the Hamiltonian circuit or disprove its existence in the graph below. (NOV/DEC
2017)

IIYEAR/IV SEMESTER

36
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT
OF IT

21. Explain the steps in building a Huffman Tree. Find the codes for the alphabets given below
as according to frequency (NOV/DEC 2017)

A 2
E 5
H 1
I 2
L 2
M 2
P 2
R 1
S 2
X 1

22. Explain the memory function for the knapsack problem and give the algorithm.
(APR/MAY 2018)
23. Apply Warsha l‘s algorithm to find the transitive closure of the digraph defined by the
following adjacency matrix
0 1 0 0
0 0 1 0
0 0 0 1
0 0 0 0
(i) Prove that the time efficiency of Warsha l‘s algorithm is cubic.(7) (APR/MAY
2018)
(ii) Explain why the time efficiency of Warsha l‘s algorithm is inferior to that of the
traversal based algorithm for spare graphs represented by their adjacency lists.(
IIYEAR/IV SEMESTER

37
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF
IT

APR/MAY 2018)
24.Explain Floyds –Warshall algorithm using dynamic programming. Trace the algorithm for
the given example. (NOV/DEC 2018)

25.Exaplain how greedy approach is used in Dijkstras algorithm for finding the sinlge-souce
shortest paths for the given graph. (NOV/DEC 2018)

26. Apply the greedy technique to find the minimum spanning tree using Prim‘s algorithm for
the given graph. (NOV/DEC 2018)

27.(i) Write the Floyd algorithm to find all pairs shortest path and derive its time complexity.

IIYEAR/IV SEMESTER

38
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF
IT

(4+3) (APR/MAY 2019)

IIYEAR/IV SEMESTER

39
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT
OF IT

( i)Solve the following using Floyd‘s algorithm. (6) (APR/MAY 2019)

28.(i) Write the Huffman code algorithm and derive its time complexity. (5+2) (APR/MAY
2019)

(ii) Generate the Huffman code for the following data comprising of alphabet and their
frequency.(6) (APR/MAY 2019)

a:1,b:1,c:2,d:3,e:5,f:8,g:13,h:21

29. a) i) compare and contrast dynamic programming and greedy method. (5)
ii) Write the algorithm for optimal binary search tree and solve the following
problem instance to construct the optimal binary search tree. Keys are
a, b, c, d and the probabilities are 0.1, 0.2, 0.4 and 0.3. (8) (APR/MAY 2021)

30. b) i) Write the prim‘s algorithm to find the minimum spanning tree and
illustrate the algorithm for the following graph. Where a, b, c, d and e are
nodes and each edges are weighted by numbers. (8) (APR/MAY 2021)

ii) What is multistage graph ? List any three applications of multistage graph. (5)

IIYEAR/IV SEMESTER

40
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

UN IT IV ITERATIVE IM
PROVEM ENT
The Simplex Method - The Maximum-F low Problem – Maximum Matching in Bipartite Graphs,
Stable marriage Problem.
PART - A

1. Define Simplex Method. (R)


The simplex method is a method for solving problems in linear programming. This
method, invented by George Dantzig in 1947, tests adjacent vertices of the feasible set
(which is a polytope) in sequence so that at each new vertex the objective function improves
or is unchanged. The simplex method is very efficient in practice, generally taking to
iterations at most (where is the number of equality constraints), and converging in expected
polynomial time for certain distributions of random inputs (Nocedal and Wright 1999,
Forsgren 2002).

2. Define feasible region. (R)


Feasible region is the set of allits feasible points. It is instructive to sketch the feasible
region in the Cartesianplane. Recall that any equation ax + by = c, where coefficients a andb
are notboth equal to zero, defines a straight line. Such a line divides the plane into twohalf-
planes: for all the points in one of them, ax + by < c, while for all the pointsin the other, ax +
by > c.

3. Write short notes on the Maximum-Flow problem. (R)


Maximum-flow algorithms require processing edges in both directions, it is
convenient to modify the adjacency matrix representation of a network as follows. If there is
a directed edge from vertex i to vertex j of capacity uij ,then the element in the ith row and
the jth column is set to uij , and the element in the jth row and the ith column is set to −uij; if
there is no edge between vertices i and j , both these elements are set to zero. Outline a
simple algorithm for identifying a source and a sink in a network presented by sucha matrix
and indicate its time efficiency.

4. Define maximum matching. (R)


In many situations we are faced with a problem of pairing elements of two sets.The
traditional example is boys and girls for a dance, but you can easily thinkof more serious
applications. It is convenient to represent elements of two givensets by vertices of a graph,
with edges between vertices that can be paired. Amatching in a graph is a subset of its edges
with the property that no two edgesshare a vertex. A maximum matching—more precisely, a
maximum cardinalitymatching— is a matching with the largest number of edges.

IIYEAR/IV SEMESTER

41
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

5. Define maximum cardinality. (R) (NOV/DEC 2016) (R) (Apr 18)


Maximum cardinality matching—is a matching with the largest number of edges. The
maximum-matching problem is the problem offinding a maximum matching in a given
graph. For an arbitrary graph, this is arather difficult problem. It was solved in 1965 by Jack
Edmonds.

6. Define Stable Marriage Problem. (R)


A marriage matching 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 fromY is paired with
exactly one woman w from X and vice versa.

7. Define maximum flow problem. (R)


The maximum flow problem can be seen as a special case of more complex network
flow problems, such as the circulation problem. The maximum value of an s-t flow (i.e., flow
from source s to sink t) is equal to the minimum capacity of an s-t cut (i.e., cut severing s
from t) in the network, as stated in the max-flow min-cut theorem.

8. Define Bipartite Graphs? (R) (Nov 17)


A bipartite graph, also called a bigraph, is a set of graph vertices decomposed into
two disjoint sets such that no two graph vertices within the same set are adjacent. A bipartite
graph is a special case of a k-partite graphwith . The illustration above shows some
bipartite graphs, with vertices in each graph colored based on to which of the two disjoint
sets they belong.

9. What do you meant by perfect matching in bipartite graph? (APR/MAY 2017) (R)
When there are an equal number of nodes on each side of a bipartite graph, a perfect
matching is an assignment of nodes on the left to nodes on the right, in such a way that
i)each node is connected by an edge to the node it is assigned to, and
ii)no two nodes on the left are assigned to the same node on the right

10. Define flow cut. (R)


Cut is a collection of arcs such that if they are removed there is no path from s to t. A
cut is said to be minimum in a network whose capacity is minimum over all cuts of the
network.

11. State Extreme point theorem. (MAY\JUNE 2016) (R) (Nov 17)
Extreme point theorem states that if S is convex and compact in a locally convex
space, then S is the closed convex hull of its extreme points: In particular, such a set has
extreme points. Convex set has its extreme points at the boundary. Extreme points should be
the end points of the line connecting any two points of convex set.

IIYEAR/IV SEMESTER

42
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

12. Define the iterative improvement technique. (NOV/DEC 2016) (R)

An iterative method is a mathematical procedure that generates a sequence of improving


approximate solutions for a class of problems, in which the n-th approximation is derived
from the previous ones

13. State: Planar coloring graph problem. (APR/MAY 2017) (R)


A graph G is planar if it can be represented by a drawing in the plane so that no edges
cross.

14. How is a transportation network represented? (R)(APR/MAY 18)

The transportation network can be represented by a connected weighted digraph with n


vertices numbered from 1 to n and a set of edges E, with the following properties:

 It contains only one vertex with no entering edges called as source and assumed to be 1.
 It contains only one vertex at end with no leaving edges called as sink and assumed as n.
 The weight uij of each directed edge (i, j) is a positive integer, called as edge capacity.

15.Describe irerative improvement technique. (NOV/DEC 2018)


Greedy techniques iteratively construct an optimal solution by building optimal solutions from
smaller problems. Iterative improvement techniques build an optimal solution by iterative
refinement of a feasible solution for the complete problem. Feasible solutions are solutions that
satisfy the constraints of the problem, for example using the denominations in the making change
problem.
The objective function is the function that problem seeks to maximize or minimize.
Iterative improvement is frequently used in numerical problems, for example root finding or
finding the maximum of a function.
16.What is solution space. Give an example. (NOV/DEC 2018)
The solution space is the set of all possible solutions for the combinatorial optimization problem.
The solution space of the Vertex Separation Problem contains all the linear orderings of the
vertices.
17.State the principle of duality. (APR/MAY 2019)
The principle of duality in Boolean algebra states that if you have a true Boolean statement
(equation) then the dual of this statement (equation) is true. The dual of a boolean statement is
found by replacing the statement‘s symbols with their counterparts. This means a ―0‖ becomes a
―1‖, ―1‖ becomes a ―0‖, ―+‖ becomes a ―.‖ and ―.‖ becomes a ―+‖.
18.Define the constraint in the context of maximum flow problem. (APR/MAY 2019)
It represents the maximum amount of flow that can pass through an edge. ... , for each
(capacity constraint: the flow of an edge cannot exceed its capacity); , for each (conservation
of flows: the sum of the flows entering a node must equal the sum of the flows exiting a node,
except for the source and the sink nodes).
IIYEAR/IV SEMESTER

43
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

19. What are the essential properties of a flow graph ?(APR/MAY 2021)
Flow graph is a directed graph. It contains the flow of control information for the set of basic
block. A control flow graph is used to depict that how the program control is being parsed among
the blocks. It is useful in the loop optimization.
20. What is meant by iterative improvement technique ? (APR/MAY 2021)
Linear programming problem (LPP) is to optimize a linear function of several variables subject
to linear constraints: maximize (or minimize) c1 x1 + ...+ cn xn subject to ai 1x1+ ...+ ain xn ≤
(or ≥ or =) bi , i = 1,...,m x1 ≥ 0, ... , xn ≥ 0 The function z = c1 x1 + ...+ cn xn is called the
objective function; constraints x1 ≥ 0, ... , xn ≥ 0 are ca led nonnegativity constraints.

PART –B
1. Explain the following: (R)
a. Blocking pair
b. Stable Marriage Problem
2. Write a pseudocode for the stable marriage algorithm. (R)
3. Determine the time-efficiency class of the stable marriage algorithm (AN)
 In the worst case
 In the best case
4. Explain the algorithm for Maximum Bipartite Matching. (R)
5. Explain in detail about simplex algorithm method. (APR/MAY 2017) (R)
6. Example Geometric Interpretation of Linear Programming. (R)
7. Explain Extreme Point Theorem? (R)
8. Write a report on the following: (R)
 Two-phase simplex method.
 Ellipsoid method.
 Bland‘s rule
 Teasible and optimal solutions
9. (i)Maximize p=2x+3y+z (MAY 2015) (E)
Subject to x+y+z≤40
2x+y-z≥10
-y+z≥10
x≥0,y≥0,z≥0
(ii) Write down the optimally condition and algorithmic implementation for finding M-
augmenting paths in bipartite graphs. (MAY 2015) (R)
10. (i)Briefly describe on the Stable marriage problem. (MAY 2015) (R) (Nov 17)
(ii)How do you compute maximum flow for the following graph using Ford-Fulkerson
method? (MAY 2015) (E)
u v

IIYEAR/IV SEMESTER

44
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

x y

IIYEAR/IV SEMESTER

45
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

11. Summarize the Simplex method. (MAY\JUNE 2016) (R) ( Nov 17) (Apr 18)
12. State and Prove Maximum Flow Min cut Theorem. (MAY\JUNE 2016) (R)
13. Apply the shortest Augmenting Path algorithm to the network shown below. (MAY\JUNE
2016) (A)

14. Explain KMP string matching algorithm for finding a pattern on the text, a analysis the
algorithm. (APR/MAY 2017) (R)

15. (i) State and prove Max-Flow Min-Cut Theorem. (8) (NOV/DEC 2016) (R)
(ii) Summarize the steps of simplex method. (8) (NOV/DEC 2016) (R)

16. (i) Explain briefly about stable marriage algorithm.(10) (NOV/DEC 2016) (R) (APR/MAY
2018)

(ii)Determine the time- efficiency class of the stable marriage algorithm (6) (NOV/DEC
2016)(E)
17.Illustrate the steps of the simplex methods with an example. (13)(NOV/DEC 2018)

18.Write the stable marriage algorithm and trace it with an instances. Analyze its running time
complexity. (13)(NOV/DEC 2018)

19.Determine the max-flow in the following network.(13) (APR/MAY 2019)

20.Solve the following set of equations using simplex algorithm: (13)(APR/MAY 2019)

IIYEAR/IV SEMESTER

46
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT
OF IT

21. a) i) Find a stable marriage matching for the instance defined by the following
ranking matrix : (8) (APR/MAY 2021)

ii) Determine the time efficiency of the above algorithm in the worst case. (5)
(APR/MAY 2021)
b) advertising alternatives for a company include television, radio and newspaper.
The table below shows the costs and estimates of audience coverage for each
types of media.

The newspaper limits the number of weekly advertisements form a single


company to ten. moreover to balance the advertising among the three types
of media, no more than half of the total number of advertisements should
occur on the radio, and at least 10% should occur on television. The weekly
advertising budget is $ 18,200. how many advertisements should run in
each of the three types of media to maximize the total audience ? solve the
problem using simplex method. (13) (APR/MAY 2021)

IIYEAR/IV SEMESTER

47
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

UN IT V
COPING WITH THELIM ITATIONS OFALGORITHMPOWER
Lower - Bound Arguments - P, NP NP- Complete and NP Hard Problems. Backtracking – n-
Queen problem - Hamiltonian Circuit Problem – Subset Sum Problem. Branch and Bound –
LIFO Search and FIFO search - Assignment problem – Knapsack Problem – Travelling
Salesman Problem - Approximation Algorithms for NP-Hard Problems – Travelling Salesman
problem – Knapsack problem.
PART - A

1. Differentiate backtracking and Exhaustive search. (AN)


S.No Backtracking Exhaustive search
1. Backtracking is to build up the Exhaustive search is simply a ―brute
solution vector one component at a – force‖ approach to combinatorial
time and to use modified criterion problems. It suggests generating
Function Pi(x1,..,xi) (sometimes each and every element of the
called bounding function) to test problem‘s domain, selecting those of
whether the vector being formed has them that satisfy the problem‘s
any chance of success. constraints, and
then finding a desired element.
2. Backtracking makes it possible to Exhaustive search is impractical for
solve many large instances of NP- large instances, however applicable
hard problems in an acceptable for small instances of problems.
amount of time.

2.What are the factors that influence the efficiency of the backtracking
algorithm?(APRIL/MAY 2008) (R)
The efficiency of the backtracking algorithm depends on the following four
factors. They are:
i. The time needed to generate the next xk
ii. The number of xk satisfying the explicit constraints.
iii. The time for the bounding functions Bk
iv. The number of xk satisfying the Bk.

3. What is backtracking?(Nov/Dec 2011) (R)


Backtracking constructs solutions one component at a time and such partially constructed
solutions are evaluated as follows ._If a partially constructed solution can be developed further
without violating the problem‘s constraints, it is done by taking the first remaining legitimate
option for the next component. ._If there is no legitimate option for the next component, no
alternatives for the remaining component need to be considered. In this case, the algorithm
backtracks to replace the last component of the partially constructed solution with its next option.

IIYEAR/IV SEMESTER

48
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

10. What is n-queens problem? (R)


The problem is to place ‗n‘ queens on an n-by-n chessboard so thatno two queens attack
each other by being in the same row or in the column orin the same

11. Draw the solution for the 4-queen problem. (R)


Q
Q
Q
Q
12. Define the Hamiltonian cycle.(NOV/DEC 2012) (R)
The Hamiltonian is defined as a cycle that passes through all the vertices of the graph
exactly once. It is named after the Irish mathematician Sir William Rowan Hamilton (1805-
1865).It is a sequence of n+1 adjacentverticesvi0, vi1… vin-1, vi0 where the first vertex of the
sequence is same as the last one while all the other n-1 vertices are distinct.

13. What is the subset-sum problem?( Nov/Dec 2012) (R)


Find a subset of a given set S={s1,………,sn} of ‗n‘ positive integers whose sum is equal to
a given positive integer ‗d‘.

14. When can a node be terminated in the subset-sum problem?(NOV/DEC 2008) (R)
The sum of the numbers included are added and given as the value for the root as s‘. The
node can be terminated as a non-promising node if either of the two equalities holds:
s‘+si+1>d (the sum s‘ is too large)

n
j i _ 1
sj  d (the sum s‘ is too sma l)

15.How can the output of a backtracking algorithm be thought of? (R)


The output of a backtracking algorithm can be thought of as an n-tuple(x1, …xn) where
each coordinate xi is an element of some finite linearlyordered set Si. If such a tuple (x1, …xi) is
not a solution, the algorithm finds thenext element in Si+1 that is consistent with the values of
(x1, …xi) and theproblem‘s constraints and adds it to the tuple as its (I+1)st coordinate. If suchan
element does not exist, the algorithm backtracks to consider the next valueof xi, and so on.

16. Give a template for a generic backtracking algorithm.(APRIL/MAY 2012) (R)


ALGORITHM Backtrack(X [1..i])
//Gives a template of a generic backtracking algorithm
//Input X[1..i] specifies the first I promising components of a solution
//Output A l the tuples representing the problem‘s solution
if X[1..i] is a solution write X[1..i]
else
IIYEAR/IV SEMESTER

49
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

X[i+1] = x
Backtrack(X[1..i+1])
17. What is the method used to find the solution in n-queen problem by symmetry? (R)
The board of the n-queens problem has several symmetries so thatsome solutions can be
obtained by other reflections. Placements in the lastn/2 columns need not be considered, because
any solution with the first queen in square can be obtained by reflection from a solutio nwith the
first queen in square (1,n-i+1)

18. State m color-ability decision problem.(NOV/DEC 2012) (R)


Let G be a graph and m be a given positive integer. We want to discover whether
thenodes of G can be colored in such a way that no two adjacent nodes have the same color yet
only m colors are used.

19.What are the two types of constraints used in Backtracking? (R)


 Explicit constraints
 Implicit constraints

20. Define implicit constraint.(APR/MAY 2010& 2012) (R)


They are rules that determine which of the tuples in the solution space of I satisfy the
criteria function. It describes the way in which the xi must relate to each other.

21. Define explicit constraint. (APR/MAY 2010& 2012) (R)


They are rules that restrict each xi to take on values only from a give set. They depend
on the particular instance I of the problem being solved. All tuples that satisfy the explicit
constraints define a possible solution space.

22. What is a promising node in the state -space tree? (R) (Nov 17)
A node in a state-space tree is said to be promising if it corresponds toa partially
constructed solution that may still lead to a complete solution.

23. What is a non-promising node in the state -space tree? (R) (Nov 17)
A node in a state-space tree is said to be promising if it corresponds toa partially
constructed solution that may still lead to a complete solution;
otherwise it is called non-promising.

24. What do leaves in the state space tree represent? (R)


Leaves in the state-space tree represent either non-promising deadends or complete solutions
found by the algorithm.

IIYEAR/IV SEMESTER

50
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

25. Define state space tree. (R)

The tree organization of the solution space is referred to as state space tree.

26. Define a live node.(APR/MAY 2010) (R)


A node which has been generated and all of whose children have not yet been
generated is called as a live node.

27. Define a dead node. (APR/MAY 2010) (R)

Dead node is defined as a generated node, which is to be expanded further all of


whose children have been generated.

28. Compared to backtracking and branch and bound?(APRIL/MAY 2008) (AN)


Backtracking Branch and bound
State-space tree is constructed using State-space tree is constructed using
depth-first search best-first search
Finds solutions for combinatorial non Finds solutions for combinatorial
optimizationproblems optimization problems
No bounds are associated with the Bounds are associated with the each
nodes in the state-space tree and every node in the state-space
tree

29. When can a search path are terminated in a branch-and-bound technique. (R)

A search path at the current node in a state-space tree of a branch and-bound algorithm can
be terminated if the value of the node‘s bound is not better than the value of the best solution
seen so far the node represents no feasible solution because the constraints of the problem are
already violated. The subset of feasible solutions represented by the node consists of asingle
point in this case compare the value of the objective function for this feasible so lution with that
of the best solution seen so far andupdate the latter with the former if the new solution is better.

30.Give the formula used to find the upper bound for knapsack problem.
A simple way to find the upper bound ‗ub‘ is to add ‗v‘, the total valueof the items already
selected, the product of the remaining capacity of theknapsack W-w and the best per unit payoff
among the remaining items, whichis vi+1/wi+1, ub = v + (W-w)( vi+1/wi+1)

31. What are NP- hard and NP-complete problems? (R)


The problems whose solutions have computing times are bounded by polynomials of
small degree.

IIYEAR/IV SEMESTER

51
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

32. Define bounding. (R)


 Branch-and-bound method searches a state space tree using any search mechanism in
which all children of the E-node are generated before another node becomes the E-node.
 Each answer node x has a cost c(x) and we have to find a minimum-cost answer node.
Common strategies include LC, FIFO, and LIFO.
 Use a cost function ˆc(·) such that ˆc(x)  c(x) provides lower bound on the solution
obtainable from any node x.

33. List example of NP hard problem. (R)

NP hard graph problem


 clique decision problem(CDP)
 Node cover decision problem(NCDP).

34. What is meant by NP hard and NP complete problem?(NOV/DEC 2011&NOV/DEC


2012) (R)

 NP-Hard Problem: A problem L is NP-hard if any only if satisfy ability reduces to L.


 NP- Complete: A problem L is NP-complete if and only if L is NP-hard and L є NP.
There are NP-hard problems that are not NP-complete.
Halting problem is NP-hard decision problem, but it is not NP-complete.

35.An NP-hard problem can be solved in deterministic polynomial time,how?(NOV/DEC


2012)

 If there is a polynomial algorithm for any NP-hard problem, then there are polynomial
algorithms for all problems in NP, and hence P = NP.
 If P ≠ NP, then NP-hard problems cannot be solved in polynomial time, while P = NP does
not resolve whether the NP-hard problems can be solved in polynomial time.

36. How NP-Hard problems are different from NP-Complete? (R)

These are the problems that are even harder than the NP-complete problems. Note that
NP-hard problems do not have to be in NP, and they do not have to be decision problems.
The precise definition here is that a problem X is NP-hard, if there is an NP-complete
problem Y, such that Y is reducible to X in polynomial time.
But since any NP-complete problem can be reduced to any other NP-complete problem
in polynomial time, all NP-complete problems can be reduced to any NP-hard problem in
polynomial time. Then, if there is a solution to one NP-hard problem in polynomial time,
there is a solution to all NP problems in polynomial time.

IIYEAR/IV SEMESTER

52
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

37. Define Hamiltonian circuit problem. (R)

Hamiltonian circuit problem Determine whether a given graph has a Hamiltonian


circuit—a path that starts and ends at the same vertex and passes through all the other vertices
exactly once.
24. State Assignment problem. (MAY\JUNE 2016) (R)
There are n people who need to be assigned to execute n jobs, one person per job. (That
is, each person is assigned to exactly one job and each job is assigned to exactly one person.)
The cost that would accrue if the ith person is assigned to the jth job is a known quantity [ , ] for
each pair , = 1, 2, . . . , . The problem is to find an assignment with the minimum total cost.

25. What is state space tree? (MAY\JUNE 2016) (R)


Backtracking and branch bound are based on the construction of a state space tree, whose
nodes reflect specific choices made for a solution‘s component .Its root represents an initial state
before the search for a solution begins. The nodes of the first level the tree represent the made for
the first component of solution, the nodes of the second evel represent the Choices for the second
components & so on.

26. Give the purpose of lower bound. (MAY\JUNE 2016) (R)


The elements are compared using operator < to make selection.
Branch and bound is an algorithm design technique that uses lower bound
comparisons.
Main purpose is to select the best lower bound.
Example: Assignment problem and transportation problem.

27. What is The Euclidean minimum spanning tree problem? (MAY\JUNE 2016) (R) (Apr
18)
The Euclidean minimum spanning tree or EMST is a minimum spanning tree of a set of n
Points in the plane where the weight of the edge between each pair of points is the Euclidean
distance between those two points. In simpler terms, an EMST connects a set of dots using lines
such that the total length of all the lines is minimized and any dot can be reached from any other
by following the lines.

28. What is an articulation point in the graph? (APR/MAY 2017) (R)


In a graph, a vertex is called an articulation point if removing it and all the edges
associated with it results in the increase of the number of connected components in the graph.

29. Define P and NP problems. (APR/MAY 2017) (R)


P- Polynomial time solving . Problems which can be solved in polynomial time, which
take time like O(n), O(n2), O(n3). Eg: finding maximum element in an array or to check whether
a string is palindrome or not. so there are many problems which can be solved in polynomial
time.

IIYEAR/IV SEMESTER

53
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

NP- Non deterministic Polynomial time solving. Problem which can't be solved in polynomial
time like TSP( travelling salesman problem)

30. Write the formula for decision tree for searching a sorted array? (NOV/DEC 2016) (R)

31. State the reason for terminating search path at the current node in branch and bound
algorithm. (NOV/DEC 2016) (R)
 The value of the node‗s bound is not better than the value of the best solution seen
so far.
 The node represents no feasible solutions because the constraints of the problem are
already violated.
 The subset of feasible solutions represented by the node consists of a single point
(and hence no further choices can be made)—in this case we compare the value of
the objective function for this feasible solution with that of the best solution seen so
far and update the latter with the former if the new solution is better.

32. Differentiate feasible solution and optimal solution. (NOV/DEC 2017)


A solution (set of values for the decision variables) for which all of the constraints in the
Solver model are satisfied is called a feasible solution. An optimal solution is a feasible solution
where the objective function reaches its maximum (or minimum) value.

33. How is lower bound found by problem reduction? (APR/MAY 2018)

34. What are tractable and non-tractable problems? (APR/MAY 2018)


Generally we think of problems that are solvable by polynomial time algorithms as being
tractable, and problems that require super polynomial time as being intractable.
35.Define P and NP problems. (NOV/DEC 2018)
All problems in P can be solved with polynomial time algorithms, whereas all problems in NP -
P are intractable.
It is not known whether P = NP. However, many problems are known in NP with the property
that if they belong to P, then it can be proved that P = NP.
If P ≠ NP, there are problems in NP that are neither in P nor in NP-Complete.
The problem belongs to class P if it‘s easy to find a solution for the problem. The problem
belongs to NP, if it‘s easy to check a solution that may have been very tedious to find.

IIYEAR/IV SEMESTER

54
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

36.Give an example for sum-of-subset problem. (NOV/DEC 2018)


Subset sum problem is to find subset of elements that are selected from a given set whose sum
adds up to a given number K. We are considering the set contains non-negative values. It is
assumed that the input set is unique (no duplicates are presented).
37.Define NP completeness and NP hard.(APR/MAY 2019)
NP-complete problems are the hardest problems in NP set. A decision problem L is NP-
complete if:
1) L is in NP (Any given solution for NP-complete problems can be verified quickly, but there is
no efficient known solution).
2) Every problem in NP is reducible to L in polynomial time (Reduction is defined below).
A problem is NP-Hard if it follows property 2 mentioned above, doesn‘t need to follow property
1. Therefore, NP-Complete set is also a subset of NP-Hard set.

38.State Hamiltonian circuit problem. (APR/MAY 2019)


A Hamiltonian circuit is defined as a cycle that passes through all the vertices of the graph
exactly once.
39.Differentiate between NP hard and NP complete problems. (APR/MAY 2021)
Problems that can be solved in polynomial time are called tractable, and problems that cannot be
solved in polynomial time are called intractable. There are several reasons for intractability.
 First, we cannot solve arbitrary instances of intractable problems in a reasonable amount of
time unless such instances are very small.
 Second, although there might be a huge difference between the running times in O(p(n)) for
polynomials of drastica ly different degrees. where p(n) is a polynomial of the problem‘s input
size n.
 Third, polynomial functions possess many convenient properties; in particular, both the sum
and composition of two polynomials are always polynomials too.  Fourth, the choice of this
class has led to a development of an extensive theory called computational complexity

40.What is Lc search and how it is efficient from other search methods in branch
and bound algorithms ? (APR/MAY 2021)

The selection rule for the next E-node does not give any preference to a node that has a very
good chance of getting the search to an answer node quickly. The search for an answer node can
be speeded by using an ―intelligent‖ ranking function c( ∙) for live nodes.

PART –B

1. Explain the n-Queen‘s problem & discuss the possible solutions.(APRIL/MAY2008)


(APIRL/MAY2009)(NOV/DEC 2008) (R)

2. Apply backtracking technique to solve the following instance of subset sum problem :
S={1,3,4,5} and d=11(NOV/DEC 2006) (AN)

IIYEAR/IV SEMESTER

55
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

3. Explain subset sum problem & discuss the possible solution strategies using backtracking.
(R)

4. Write a recursive backtracking algorithm to find all the Hamiltonian cycles of a given graph.
(APIRL/MAY2009) (NOV/DEC 2008) (E)

5. What is backtracking explain detail (APR/MAY 2007) (R)

6. Explain graph coloring in detail. (APIRL/MAY2009) (R)

7. Give the backtracking algorithm for knapsack problem. (R)

8. Explain the algorithm for finding all m-colorings of a graph.(APRIL/MAY 2012) (R)

9. Describe the backtracking solution to solve 8-Queens problem.(APRIL/MAY 2010)


(APRIL/MAY2012) (APR/MAY 2017) (A)
10. With an example, explain Graph Coloring Algorithm.(APRIL/MAY 2010) (R)

11. Explain the n-Queen‘s problem and trace it for n=6.(APRIL/MAY 2011) (A)

12.(i)Explain Hamiltonian cycles. (NOV/DEC 2012) (8) (R)

(ii) With an example, explains Graph Coloring Algorithm (8) (R)


`
13. (i)Explain the control abstraction for Backtracking method. Describe the backtracking
solution to solve 8-Queens problem. (8)(NOV/DEC 2012) (A)
(ii) Let w= {5, 7, 10, 12, 15, 18, 20} and m=35.Find all possible subset of w whose sum is
equivalent to m.Draw the portion of state space tree for this problem. (8) (A)
14. How backtracking works on 8-Queens problem with suitable example? (MAY/JUNE 2013)
(A)

15.(i) Give the backtracking algorithm for knapsack problem. (MAY/JUNE 2013) (8)
(ii) Explain elaborately recursive backtracking algorithm. (8) (R)

16. Using backtracking, find the optimal solution to a knapsack problem for the knapsack
instance n=8, m=110,(p1…p7)=(11,21,31,33,43,53,55,65) and
(w1…w7)=(1,11,21,33,43,53,55,65). (A)

17. Write an algorithm to determine Hamiltonian cycle in a given graph using back tracking.
For the following graph determine the Hamiltonian cycle. (A)

A B

IIYEAR/IV SEMESTER

56
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

C F

D E

IIYEAR/IV SEMESTER

57
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

18. Write an algorithm to determine the Sum of Subsets for a given sum and a Set of numbers.
Draw the tree representation to solve the subset sum problem given the numbers set as {3, 5,
6, 7, 2} with the sum=15. Derive all the subsets. (A)

19. Write an algorithm for N QUEENS problem and Trace it for n=6. (R)

20. What is Branch and bound? Explain in detail.(MAY/JUNE 07) (APIRL/MAY2009)


(NOV/DEC 2008) (APR/MAY 2017) (R)

21. (i)Suggest an approximation algorithm for travelling salesperson problem. Assume that the
cost function satisfies the triangle inequality. (MAY 2015) (R)
(ii)Explain how job assignment problem could be solved, given n tasks and n agents where
each agent has a cost to complete each task, using branch and bound. (MAY 2015) (AN)
22. (i)The knight is placed on the first block of an empty board and, moving according to the
rules of chess, must visit each square exactly once. Solve the above problem using
backtracking procedure. (MAY 2015) (AN)
(ii)Implement an algorithm for Knapsack problem using NP-Hard approach. (MAY 2015)
(R)
23. State the subset-sum problem and Complete state-space tree of the backtracking algorithm
applied to the instance A={3, 5, 6, 7} and d=15 of the subset-sum problem.(MAY\JUNE
2016) (A)
24. (i) Draw a decision tree and find the number of key comparisons in the worst and average
cases for the three element bubble sort. (8) (NOV/DEC 2016) (AN)
( i) Write backtracking algorithm for 4 queen‘s problem and discuss the possible solution. (8)
(NOV/DEC 2016) (R)
25. Solve the following instance of knapsack problem by branch and bound algorithm W=
15.(16) (NOV/DEC 2016) (AN)

ITEM WEIG PROFI


S HT T

1 5 40

2 7 35

3 2 18

IIYEAR/IV SEMESTER

58
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

4 4 4

5 5 10

6 1 2

26. Discuss the approximation algorithm for NP hard problem? (NOV/DEC 2016) (R)

27. Apply Branch and bound algorithm to solve the travelling salesman problem. (NOV/DEC
2016) (A)

28. Give the methods for Establishing Lower Bound. (NOV/DEC 17)

29. Find the optimal solution using branch and bound for the following assignment problem.

30. What is class NP? Discuss about any five problems for which no polynomial time for TSP
problem. (APR/MAY 2018)
31. Elaborate on the nearest-neighbor algorithm and multifragment- heuristic algorithm for TSP
problem. (APR/MAY 2018)
32. Consider the travelling salesperson instances defined by the following cost matrix.
(NOV/DEC 2018)

Draw the state space and show the reduced matrices corresponding to each of the node.
(13)(NOV/DEC 2018)
33. Discuss the approximation algorithm for NP-hard problem. (13)(NOV/DEC 2018)
34. Write an algorithm to solve the travelling salesman problem and prove that it is a 2 time
approximation algorithm.(13)(APR/MAY 2019)
IIYEAR/IV SEMESTER

59
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

35. Write an algorithm for subset sum and explain with an example. (13)(APR/MAY 2019)
36.Explain the 4-queens problem using backtracking. Write the algorithms . Giv the estimated
cost for all possible solutions of 4-queens problem.Specify the implicit and explicit constrints.
(APR/MAY 2019)

36. 15. a) i) What are the general approaches exit for branch and bound algorithms ?
also explain the data structure need for storing live nodes in each approach
with suitable example. (5)
ii) Write the algorithm for solving 0/1 knapsack problem using Lc branch
and bound and solve the knapsack instance ; n = 4; (p1, p2, p3, p4) = (10,
10, 12, 18); (w1, w2, w3, w4) = (2, 4, 6, 9) and m = 15, using LcBB, Draw
the state space tree. (8) (APR/MAY 2021)

37. b) i) Write the algorithm for sum of subsets problem using backtracking technique. (8)
ii) illustrate the algorithm for the instance n = 6, m = 30 and W = (5, 10, 12,
13, 15, 18). Draw possible state space tree. (5) (APR/MAY 2021)

38. a) i) assume {500, 100, 50, 20, 10, 5} currency of denominations is available
in a bank. Devise a greedy algorithm to obtain the minimum number of
denominations for any amount which is a multiple of 5. Find the time
complexity of your algorithm. (5)
ii) Explain the maximum-bipartite-matching problem with an illustration. (5)
iii) Prove that TsP problem is NP complete, assuming that hamiltonian
problem is NP complete. (5) (APR/MAY 2021)
b.i) solve the TsP using branch and bound technique. (APR/MAY 2021)

ii) Explain the operations of approximate vertex cover and give an example of
a graph for which aPPRox-vERTEx-covER always yields a suboptimal
solution. (APR/MAY 2021)

COURSE OUTCOMES: Ability to apply algorithm design techniques to solve certain NP-
complete problems.

IIYEAR/IV SEMESTER

60
PANIMALAR INSTITUTE OF TECHNOLOGY DEPARTMENT OF IT

Course Name : CS8451- DESIGN AND ANALYSIS OF ALGORITHMS


Year/Semester : II/ IV
Year of Study : 2021 –2022 (R – 2017)
On Completion of this course student will be able to
COURSE OUTCOMES
CO DESCRIPTION
CO1 An ability to understand algorithm analysis techniques and analyze asymptotic runtime
complexity of algorithms including formulating recurrence relations.
CO2 Apply the algorithms and design techniques to solve problems using brute force and divide
and conquer.
CO3 An ability to design and analyze algorithms using dynamic programming and greedy
strategy.
CO4 An ability to design and analyze algorithms using max flow – maximum matching.
CO5 An ability to analyze the limitations of Algorithm power.
CO-PO M ATRIX:

PO1 PO1 PO1


CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9
0 1 2
CO.1 3 3 3 3 - - - - - - - 2

CO.2 1 2 3 3 - - - - - - - 1

CO.3 1 3 2 2 - - - - - - - 1

CO.4 2 3 2 3 - - - - - - - 1

CO.5 3 3 2 2 - - - - - - - 1

CO 2 2.8 2.4 2.6 - - - - - - - 1.2


CO – PSO M ATRIX:

CO PSO1 PSO2 PSO3


CO.1 1 3 3

CO.2 1 2 1

CO.3 1 2 1

CO.4 1 1 2

CO.5 1 3 3

CO 1 2.2 2

IIYEAR/IV SEMESTER

61

You might also like