Beruflich Dokumente
Kultur Dokumente
Elambalur, Perambalur-621212
DEPARTMENT OF CSE
CS 2251 DESIGN AND ANALYSIS OF ALGORITHMS
UNIT-I ALGORITHM ANALYSIS
1. Define Algorithm.
An algorithm is a finite set of instructions that if followed, accomplishes
particular task.
An algorithm is step by step procedure to solve a problem.
Compilation Time:
Compilation is the time taken to compile an algorithm and it checks the
syntax and semantic errors in the program.
Running Time:
It is the time to execute the compiled program and It depends upon the
number of instructions present in the algorithm.
14. What are the common running times for big-oh notations?
Some common running times for algorithm based on big-oh notations are
Linear time O (n)
Quadratic time O (n2 )
Exponential time O (2n )
Polynomial time O (nk )
Logarithmic time O (log n)
The recurrence equation for the worst case behavior o f merge sort is
T(n)=2T(n/2)+n-1 for n>1, T worst (1)=0
We are given n objects and a knapsack or bag. Object i has a weight wi and the
knapsack has a capacity m. If a fraction xi, 0<= xi<=1, of object i is placed into the
knapsack, then a profit pi xi is earned. The objective is to obtain a filling of the knapsack
that maximizes the total profit earned.
* Binary search
* Merge sort
To search for an element in the list, the binary search algorithms split the list and
locate the middle element of the list.
Merits:
* It requires less running time
A binary search tree is one of the most important data structures in computer
science. Their principle applications are to implement a dictionary, a set of elements with
the operations of searching, insertion and deletion. Its probability of searching for
elements of a set is known as optimal binary search tree, it requires only average number
of comparison in a search.
2. What is dynamic programming?
Given a weighted connected graph, the all pair shortest path problem is to find the
distance from each vertex to all other vertices.
Let G=(v, e) be directed graph with edge cost C ij. The variable Cij defined such
that Cij>0 for all i and j and Cij= if(i,j) E. Let |V| = n and n>1. A 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 sales person problem is to find a tour of
minimum cost.
UNIT-IV BACKTRACKING
2. Define backtracking?
It is a kind of solving problem by trial and error. We make sure that we never try
the same thing twice, we also make sure that if the problem is finite, and we will
eventually try all possibilities.
Backtracking problem require that all the solutions satisfy the complex set of constraints.
3. What is Hamiltonian cycle in an undirected graph?
A Hamiltonian cycle is a round trip along n edges of G that visits every vertex
once and returns to its starting position.
4. What is meant by state space tree?
* Answer states are those solution state S for which the path from the root to S defines
a tuple that is a member of the set of solutions.
5. Explain the term solution state, Ans wer state, E-node and dead node.
Solution state: The problem state S for which the path from the root to S define a tuple in
the solution space.
Answer state: Leaf node which corresponds to an element in the set of solution.
Backtracking problem require that all the solution satisfy a complex set of
constraints. There are two types of constraints are
* Implicit constraint
* Explicit constraint
7. Define 8-queen proble m.
To identify whether the 2 queens on the same diagonal it must satisfy the
following conditions.
* Also every element on the same diagonal that goes from the upper right to lower
left have the same (row+column) value.
We are given a distinct positive numbers and we desire to find all combination of
these numbers, whose sums are m. This is called the sum of subsets problem.
For a given graph, find the smallest number of colors, the need to be assigned to
the graphs, vertices, so that no 2 adjacent vertices are assigned the same color.
11. Define chromatic number?
The chromatic number of a graph G is the smallest number of color need to color
the verities of G, so that no 2 adjacent vertices shave the same color.
12. Differentiate between promising and non promising node in 0/1 knapsack
proble m.
Promising Node: Its weight less than the capacity of knapsack, upper bound>max profit
and the node can be expanded further.
Non promising Node: its weight greater than the capacity of knapsack, upper bound<
max profit and the node cannot be expanded further.
* When this new vertex has been explored the exploration of V continues.
* The search terminates when all reached vertices have been fully explored.
* Using BFS all newly visited vertices are put on to the list.
* Sub graph formed by the vertices on this list make up a connected component.
For every vertex V in depth first spanning tree, we compute the L(u) that is reachable
from V by taking zero or more edges and then possible one back edge.
* FIFO search
* LIFO search
* LC search