Cs8451 Design and Analysis of Algorithms: Unit-I Part-A 1. Define Algorithm
Cs8451 Design and Analysis of Algorithms: Unit-I Part-A 1. Define Algorithm
Cs8451 Design and Analysis of Algorithms: Unit-I Part-A 1. Define Algorithm
in
UNIT-I
PART-A
1. Define algorithm.
Time Efficiency measured by counting the number of times the algorithms basic
operation is executed. Space Efficiency is measured by counting the number of extra
memory units consumed by the algorithm.
13. What are the features of efficient algorithm?
Free of ambiguity
Efficient in execution time
Concise and compact Completeness
Definiteness Finiteness
Step do
statement 1
statement n
Algorithm sum(a,n)
{ S : = 0.0
For i=1 to n do
S : - S + a[i];
Return S;
if(n≤ 0) then
return 0.0;
The difference between Big O notation and Big Omega notation is that Big O is used to
describe the worst case running time for an algorithm. But, Big Omega notation, on the
other hand, is used to describe the best case running time for a given algorithm.
PART-B
UNIT-II
PART-A
1. What is Empirical Analysis?
It is performed by running a program implementing the algorithm on a sample of
inputs and analyzing the data observed. This involves generating pseudo code and
random numbers.
dividing it into several smaller instance, solving of them recursively, and then
combining their solutions to the original instance of the Problem.
5. Define O-Notation.
A function t(n) is said to be O (g(n)), denoted t(n) C O (g(n)), if t(n) is bounded
above by some constant multiple of g(n) for all large n, ie ., if there exist some positive
constant c and some nonnegative integer 0 such that
t(n) <= cg(n) for all>=0
11. What are the different criteria used to improve the effectiveness of algorithm?
Input- Zero or more quantities are externally supplied .
Output-At least one quantity is produced
Definiteness-Each instruction is clear and unambiguous
www.studymaterialz.in
Finiteness-If we trace out the instructions of algorithm, then for all case the
algorithm terminates after finite number of steps
Effectiveness-Every instruction must be very clear
17.Define profiling?
Profiling is an important resource the empirical analysis of an algorithm running time.
Measuring n different segments of program can pinpoint a bottleneck in the program’s
performance that can be missed by an abstract deliberation about the algorithm’s basic
operations. The process of getting such data is called profiling.
www.studymaterialz.in
Successful searches
for i = 2 to n
do
if(a[i] >max)
}}
PART-B
1. Devise an algorithm to sort the following elements using merge sort technique
2. 286, 45,278,368,475,389,656,788,503,126
3. Write an efficient and exhaustive search algorithm for the traveling salesman
problem.
4. Explain Binary search in detail.
6. Solve the recurrence for the number of additions required by strassen’s algorithm.
(Assume that n is a power of 2)
7. Implement in C, the divide and conquer closest pair algorithm.
www.studymaterialz.in
8. Explain the upper and lower hulls in the convex-hull problem, with an example.
9. Give a specific example of inputs that make the quickhull algorithm run in quadratic
time.
UNIT III
PART-A
Instance simplification
Representation change
Problem reduction
The choice made by greedy algorithm depends on choices made so far but it
cannot depend on any future choices or on solution to the sub problem.
It progresses in top down fashion.
25. Write the difference between the Greedy method and Dynamic programming.
PART-B
1. Apply Floyd’s algorithm or obtain all pair shortest path for the following graph.
Explain with the algorithm.
2. Solve the following instance of the 0/1 Knapsack problem for the given knapsack
capacity M=5.
UNIT-IV
PART-A
1. Define rotation?
A rotation in an AVL tree is a local transformation of its sub tree rooted at a node,
which is performed, when the balance factor of a node either +2 or -2.If an insertion or
deletion of a new node in AVL Tree creates a tree with a violated balance requirement,
then the tree is restructured by performing special transformation called rotation, that
restore the balance required.
2. What are the different type’s rotations?
The four types of rotations are.
Right rotation
Left rotation
Double right-left rotation
Double left right rotation.
5. Define Heap.
Heap is partially ordered data structure that is especially suitable for implementing
priority queues. A heap is said to be a max heap, then the children of every node have a
value less than that node. A heap is said to be a min heap, then the children of every node
have a value greater than node
PART-B
5. Explain how the maximum flow problem for a network with several sources and
sinks can be transformed into the same problem for a network with a single source
and a single link.
6. Define the following: source, sink, capacity, flow network and preflow.
7. Proof a matching M is maximal if and only if there exists no augmenting path
with respect to M.
8. Write an algorithm for Maximum Bipartite matching with example.
UNIT V
PART-A
1. Define backtracking.
Depth first node generation with bounding function is called backtracking. The backtracking
algorithm has its virtue the ability to yield the answer with far fewer than m trials.
A Hamiltonian cycle is round trip along n edges of G that visits every vertex once
and returns to its starting position.
3. What is feasible solution?
It is obtained from given n inputs Subsets that satisfies some constraints are called
feasible solution. It is obtained based on some constraints
8. What is heuristic?
A heuristic is common sense rule drawn from experience rather than from
mathematically proved assertion.
For example, going to the nearest unvisited city in the travelling salesman
problem is good example for heuristic.
10. Give the upper bound and lower bound of matrix multiplication algorithm?
Upper bound: The given algorithm does n*n*n multiplication hence at most
n*n*n multiplication are necessary.
Lower bound: It has been proved in the literature that at least n*n multiplications
are necessary.
The nodes of the first level the tree represent the made for the first component of
solution; the nodes of the second even represent the Choices for the second components
& so on.
13. What are the additional items are required for branch and bound compare to
backtracking technique?
Compared to backtracking, branch and bound requires 2 additional items.
1) A way to proved , for every node of node of state space tree, a bound on the best
value of the objective function on any solution that can be obtain d by adding further
components to the partial solution represented by the node.
2) The value of the best solution seen so far.
22. What are the requirements that are needed for performing Backtracking?
To solve any problem using backtracking, it requires that all the solutions satisfy a
complex set of constraints. They are:
i. Explicit constraints.
ii. Implicit constraints.
2. Solve the following instance of the knapsack problem by the branch & bound
algorithm.
www.studymaterialz.in
α 21 42 31 6 24
11 α 17 7 35 18
25 5 α 27 14 9
12 9 24 α 30 12
14 7 21 15 α 48
40 15 16 5 20 α
5. Explain how branch and bound technique is used to solve 0/1 knapsack problem.
for n=4 , W=10, (p1,p2,p3,p4) = (40,42,25,12) and (w1,w2,w3,w4) = (4,7,5,3).
7. Explain about assignment problem using branch and bound with example.
8. Discuss the solution for travelling salesman problem using branch & bound
technique.
9. Discuss the decision trees for sorting algorithms.
UNIT – I
PART-A
Program execution
I/O Operation
File-System manipulation
Communications