0% found this document useful (0 votes)
117 views23 pages

DAA-University 2mark Questions and Answers

The document discusses various algorithm analysis concepts. It defines big O notation and provides examples of time complexities of common algorithms like linear, logarithmic, quadratic, and exponential. It also defines recurrence relations, divide and conquer algorithms, and the master's theorem for solving divide and conquer recurrences.

Uploaded by

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

DAA-University 2mark Questions and Answers

The document discusses various algorithm analysis concepts. It defines big O notation and provides examples of time complexities of common algorithms like linear, logarithmic, quadratic, and exponential. It also defines recurrence relations, divide and conquer algorithms, and the master's theorem for solving divide and conquer recurrences.

Uploaded by

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

University 2mark Questions and answers

Unit 1

1. Small O notation-define.( APRIL 2016)


A function f(n) is said to be in O(g(n)), denoted by f(n) = O(g(n)), if there exist some positive
constant c and some non-negative integer no such that
f(n) < = c g (n) for all n > = no
2.Give the worst case analysis and give example. .( APRIL 2016)

a. the worst-case complexity of the algorithm is the function defined by the maximum


number of steps taken on any instance of size n. It represents the curve passing
through the highest point of each column.  
b. The best-case complexity of the algorithm is the function defined by the minimum
number of steps taken on any instance of size n. It represents the curve passing
through the lowest point of each column.  
c. Finally, the average-case complexity of the algorithm is the function defined by the
average number of steps taken on any instance of size n.  

Notation Name Examples

Determining if a number is even or odd; Using a


constant constant-size lookup table; Using a suitable hash
function for looking up an item.

Finding an item in a sorted array with a binary search or


logarithmic a balanced search tree as well as all operations in a
Binomial heap.

Finding an item in an unsorted list or a malformed tree


linear (worst case) or in an unsorted array; Adding two n-bit
integers by ripple carry.

linearithmic,
Performing a Fast Fourier transform; heapsort, quicksort
loglinear, or
(best and average case), or merge sort
quasilinear

Multiplying two n-digit numbers by a simple algorithm;


bubble sort (worst case or naive implementation), Shell
quadratic
sort, quicksort (worst case), selection sort or insertion
sort

Finding the (exact) solution to the travelling salesman


problem using dynamic programming; determining if
exponential
two logical statements are equivalent using brute-force
search
3. Define algorithm and give its criteria. (NOV 2016)

An Algorithm is a finite set of instruction to accomplish a particular task.


The criteria of an Algorithm are:-
1) Input: Zero or more quantities are externally supplied.
2) Output: At least one quantity is produced.
3) Definiteness: Each instruction is clear and unambiguous.
4) Finiteness: The Algorithm terminates after finite number of steps.
5) Effectiveness: Every instruction must be very basic and feasible.

4. Define homogeneous and Inhomogeneous recurrences. . (NOV 2016)


Homogeneous
Recurrences that end after a finite number of steps are called as homogenous
recurrence, the equation finally obtained infinitely has many solutions, they are
basically in linear form
aotn + a1tn-1 + . . . aktn-k = 0

Inhomogenous recurrence?
The solution of linear recurrence with constant co-efficient becomes
more difficult when the recurrence is not homogenous, that is when linear
combination, is not equal to zero.
aotn + a1tn-1 + . . . aktn-k = bnp(n).
5.What are the control structures? ( APRIL 2015)

A control structure is a block of programming that analyzes variables and chooses a direction
in which to go based on given parameters. The term flow control details the direction the
program takes (which way program control "flows")

6. Compare linear and binary search. ( APRIL 2015)

o linear search or sequential search is a method for finding a target value within a list.
o It sequentially checks each element of the list for the target value until a
match is found or until all the elements have been searched.
o binary search or half-interval search algorithm finds the position of a target
valuewithin a sorted array.
o The binary search algorithm can be classified as a dichotomy divide-and-conquer
search algorithm and executes in logarithmic time.

7.Define asymptotic notation.( APRIL 2015)

Asymptotic complexity is a way of expressing the main component of the cost of an


algorithm, using idealized (not comparable) units of computational work.

Various asymptotic notation.

i) Big oh Notation – ‘O’


ii) Omega Notation – ‘Ω’
iii) Theta Notation – ‘θ’

Big oh ‘O’ – notation mean?


A function f(n) is said to be in O(g(n)), denoted by f(n) = O(g(n)), if there exist some
positive constant c and some non-negative integer no such that
f(n) < = c g (n) for all n > = no

Omega ’Ω’- notation mean?


A function f(n) is said to be in the Ω(g(n)) denoted by f(n) = Ω(g(n)), if there exist
some positive constant c and some non-negative integer n o such that
f(n) >= c g (n) for all n > = no

Theta ‘θ’- notation mean?


A function f(n) is said to be in θ(g(n)) denoted by f(n) = θ(g(n)), if there exist some
positive constant C1 and C2 and some non negative integer no such that
C2g (n) <= f(n) <= C1 g(n) for n > = no.

8. What is algorithm’s optimality?( NOV 2015)

The principle of optimality states that an optimal sequence of decisions has the property that
whatever the initial state and decisions are, the remaining decisions must constitute an
optimal decision sequence with regard to state resulting from first decision.
9. Define order of growth. ( NOV 2015)

Order of growth in algorithm means how the time for computation increases when you
increase the input size. It really matters when your input size is very large. Order of
growth provide only a crude description of the behavior of a process. Depending on
the algorithm, the behaviour changes.

10.Define recurrence relation. (NOV 2014)

A recurrence relation for the sequence {an} is an equation that expresses an in


terms of one or more of the previous terms of the sequence, namely a 0, a1, …, a n-1, for all
integers n, with n ³ n0, where n0 is a nonnegative integer.
.
11.How do you measure the efficiency of an algorithm?( April 2014)

The efficiency of an algorithm can be computed by determining the amount of


resources it consumes. The primary resources that an algorithm consumes are: 
·

Time: The CPU time required to execute the algorithm 


Space: The amount of memory used by the algorithm for execution 
The lesser resources that an algorithm uses, the more efficient it is. 

12.what is big “oh” notation? (NOV 2014)


Define Big ‘Oh’ notation (April 2014)

A function f(n) is said to be in O(g(n)), denoted by f(n) = O(g(n)), if there exist some positive
constant c and some non-negative integer no such that

f(n) < = c g (n) for all n > = no


13. What are the control structures? ( APRIL 2015)

A control structure is a block of programming that analyzes variables and chooses a


direction in which to go based on given parameters. The term flow control details the
direction the program takes (which way program control "flows")

Unit-2

1.Define master’s theorem. .( APRIL 2016)

Master Method is a direct way to get the solution. The master method works only for following type
of recurrences or for recurrences that can be transformed to following type.

T(n) = aT(n/b) + f(n) where a >= 1 and b > 1

There are following three cases:


1. If f(n) = Θ(nc) where c <Logba then T(n) = Θ(nLogba)
2. If f(n) = Θ(nc) where c = Logba then T(n) = Θ(ncLog n)
3.If f(n) = Θ(nc) where c >Logba then T(n) = Θ(f(n))

How does this work?


Master method is mainly derived from recurrence tree method. If we draw recurrence tree of T(n) =
aT(n/b) + f(n), we can see that the work done at root is f(n) and work done at all leaves is Θ(n c) where
c is Logba. And the height of recurrence tree is Logbn

3. What are divide and conquer method?(APRIL 2015)

In divide and conquer approach, a problem is divided into smaller problems, then
the smaller problems are solved independently, and finally the solutions of smaller problems
are combined into a solution for the large problem.
Generally, divide-and-conquer algorithms have three parts
 Divide the problem into a number of sub-problems that are
smaller instances of the same problem.
 Conquer the sub-problems by solving them recursively. If they
are small enough, solve the sub-problems as base cases.
 Combine the solutions to the sub-problems into the solution for
the original problem.
Pros and cons of Divide and Conquer Approach
 Divide and conquer approach supports parallelism as sub-problems are independent.
Hence, an algorithm, which is designed using this technique, can run on the
multiprocessor system or in different machines simultaneously.
 In this approach, most of the algorithms are designed using recursion, hence memory
management is very high. For recursive function stack is used, where function state
needs to be stored.
Application of Divide and Conquer Approach
Following are some problems, which are solved using divide and conquer approach.
 Finding the maximum and minimum of a sequence of numbers
 Strassen’s matrix multiplication
 Merge sort
 Binary search
2. Define greedy technique ( APRIL 2016)

 Greedy algorithm is an algorithmic paradigm based on heuristic that follows local optimal choice at
each step with the hope of finding global optimal solution.
Components of Greedy Algorithm
Greedy algorithms have the following five components −
 A candidate set − A solution is created from this set.
 A selection function − Used to choose the best candidate to be added to the solution.
 A feasibility function − Used to determine whether a candidate can be used to contribute to
the solution.
 An objective function − Used to assign a value to a solution or a partial solution.
 A solution function − Used to indicate whether a complete solution has been reached.

3.State the best and worst case of binary search algorithm.(NOV 2016)

Time complexity for successful search


Best case : T(n) = O(1)
Average case : T(n) = O(log n)
Worst case : T(n) = O(log n)
Time complexity for unsuccessful search
T(n) > = O(log n)
4.Define shortest path (NOV 2016)

In graph theory, the shortest path problem is the problem of finding a path between two
vertices (or nodes) in a graph such that the sum of the weights of its constituent edges is
minimized.

6. Compare linear and binary search. (APRIL 2015)

Linear search or sequential search is a method for finding a target value within a list. It sequentially
checks each element of the list for the target value until a match is found or until all the elements have
been searched.

Binary search or half-interval search algorithm finds the position of a target value within a sorted
array. The binary search algorithm can be classified as a dichotomic divide-and-conquer search
algorithm and executes in logarithmic time.

7. Give the recurrence relation of divide and conquer. ( NOV 2015)

 Suppose that a rec. algorithm divides a problem of size n into a parts, where each sub-
problem is of size n/b. Also suppose that a total number of g(n) extra operations are
needed in the conquer step of the algorithm to combine the solutions of the sub-problems
into a solution of the original problem. Let f(n) be the number of operations required to
solve the problem of size n. Then f satisfies the recurrence relation f(n)=a f(n/b)+g(n)
and it is called divide-and-conquer recurrence relation.
Example:

1) Consider the case in which a=2 and b=2. Let T(1)=2 & f(n)=n.
We have,

T(n) = 2T(n/2)+n

= 2[2T(n/2/2)+n/2]+n

= [4T(n/4)+n]+n

= 4T(n/4)+2n

= 4[2T(n/4/2)+n/4]+2n
= 4[2T(n/8)+n/4]+2n

= 8T(n/8)+n+2n

= 8T(n/8)+3n

8.Write any two characteristics of greedy algorithm. ( NOV 2015)

The greedy method is straight forward design technique which has n inputs and to obtain a subset
that satisfies some constraints.

 Any subset that satisfies the constraints is called a feasible solution.


 A feasible solution that either maximizes (or) minimizes a given objective function is called
an optimal solution.

9.Analyze the various cases of complexity for Binary Search. (NOV 2014)

Time complexity for successful search


Best case : T(n) = O(1)
Average case : T(n) = O(log n)
Worst case : T(n) = O(log n)
Time complexity for unsuccessful search
T(n) > = O(log n)

10.What are the drawback s of greedy algorithm? (April 2014)

Following are the demerits of greedy method:

 Greedy method is comparatively efficient than divide and conquer but there is no such
guarantee of getting optimum solution
 In greedy method the optimum selection is without revising previously generated solutions
 In many problems, Greedy algorithm fails to find an optimal solution, moreover it may
produce a worst solution. Problems like Travelling Salesman and Knapsack cannot be solved
using this approach.

11.What is the time complexity of binary search?

Time complexity for successful search


Best case : T(n) = O(1)
Average case : T(n) = O(log n)
Worst case : T(n) = O(log n)
Time complexity for unsuccessful search
T(n) > = O(log n)
12. What is main objective of fractionalknapsack problem? ( APRIL 2015)

The objective of the knapsack problem is to fill the knapsack with capacity ’m’ by including or
excluding full (or) fractional amounts of different n objects in which summation of weight of the
object must be less than or equal to the capacity of the knapsack ‘m' and summation of profit of the
object must be maximum

n
Maximize ∑ pixi
i=1

n
Subject to ∑ wixi<= m
i=1

xi ϵ {0,0-1,1}

where 1<=i<=n

ADDITIONAL QUESTIONS :

13. What is job scheduling with dead line?

 In this problem we have n jobs j1, j2, … jn each has an associated deadline d1, d2, … dn and
profit p1, p2, ... pn.
 Profit will only be awarded or earned if the job is completed on or before the deadline.
 We assume that each job takes unit time to complete.
 The objective is to earn maximum profit when only one job can be scheduled or processed at
any given time.

14. What is spanning tree?List out the methods to construct spanning tree?

 A spanning tree is a subgraph of Graph G, which has all the vertices (n vertices) covered
with minimum possible number of edges(n-1 edges) and does not have cycle .
 Hence, a spanning tree does not have cycles and it cannot be disconnected..

Methods to construct spanning tree:

1.Prim's method

2.Kruskal's method
15. what is optimal merge pattern?

Definition: Merge n sorted sequences of different lengths into one output while minimizing reads.
Only two sequences can be merged at once. At each step, the two shortest sequences are merged.

Formal Definition: Let D={n1, ... , nk} be the set of lengths of sequences to be merged. Take the two
shortest sequences, ni, nj∈ D, such that n≥ ni and n≥ nj ∀ n∈ D. Merge these two sequences. The new
set D is D' = (D - {ni, nj}) ∪ {ni+nj}. Repeat until there is only one sequence.

For example, let there be a set of sorted sequences of the following lengths: D={3,5,7,9,12,14,15,17}.
Building the optimal merge tree goes as follows.
3 5 7 9 12 14 15 17

8 7 9 12 14 15 17
/ \
3 5

15 9 12 14 15 17
/ \
8 7
/ \
3 5

15 21 14 15 17
/ \ / \
8 7 9 12
/ \
3 5

29 21 15 17
/ \ / \
14 15 9 12
/ \
8 7
/ \
3 5

29 21 32
/ \ / \ / \
14 15 9 12 15 17
/ \
8 7
/ \
3 5

50 32
/ \ / \
/ \ 15 17
29 21
/ \ / \
14 15 9 12
/ \
8 7
/ \
3 5
82
/ \
/ \
/ \
50 32
/ \ / \
/ \ 15 17
29 21
/ \ / \
14 15 9 12
/ \
8 7
/ \
3 5

16. What is optimal storage on tape?

 We have 3 programs which are stored in a sequential magnetic tape,the length of the
programs are (l1.l2,l3).
 The problem is to find the order of the program which minimize the mean retrieval
time of those programs.

17. What is Strassen matrix multiplication and write its complexity

Since the cost of multiplication is more expensive than addition,we can reformulate the
equation for Cij using fewer number of multiplication and more number of additions and subtractions.

To reformulate the equation ,Strasson has discovered a method to compute C ij using 7


multiplication and 18 additions/subtractions.

The complexity of the Strasson method can be written as the following recurrence relation,

T(n)= { b if n==2

{T(n/2)tan2 if n>2

where a,b are known constants


T(n)=O(n2.8)
Unit 3

PART A

1. Advantage of dynamic programming. .( APRIL 2016)

 Dynamic Programming solves problems by combining the solutions of sub problems.


 Dynamic Programming algorithm solves each sub-problem just once and then saves
its answer in a table, thereby avoiding the work of re-computing the answer every
time.
 The optimal solution of the given problem can be obtained using optimal solutions of
its sub-problems.
 It definitely gives optimal solution always.

2. Define topological sorting. .( APRIL 2016)

A topological sort or topological ordering of a directed graph is a linear ordering of


its vertices such that for every directed edge uv from vertex u to vertex v, u comes
before v in the ordering. For instance, the vertices of the graph may represent tasks to
be performed, and the edges may represent constraints that one task must be performed before
another; in this application, a topological ordering is just a valid sequence for the tasks. A topological
ordering is possible if and only if the graph has no directed cycles.

3. What is dynamic programming. . (NOV 2016)


What is dynamic programming?(APRIL 2015)
Define dynamic programming. (NOV 2014)

Dynamic Programming is also used in optimization problems. Like divide-


and-conquer method, Dynamic Programming solves problems by combining the solutions of
subproblems. Moreover, Dynamic Programming algorithm solves each sub-problem just
once and then saves its answer in a table, thereby avoiding the work of re-computing the
answer every time.
Two main properties of a problem suggest that the given problem can be solved using
Dynamic Programming. These properties are overlapping sub-problems and optimal
substructure.
Steps of Dynamic Programming Approach
Dynamic Programming algorithm is designed using the following four steps −
 Characterize the structure of an optimal solution.
 Recursively define the value of an optimal solution.
 Compute the value of an optimal solution, typically in a bottom-up fashion.
 Construct an optimal solution from the computed information.

4. What is principle of optimality?( NOV 2015)

The principle of optimality states that an optimal sequence of decisions has the property that
whatever the initial state and decisions are, the remaining decisions must constitute an
optimal decision sequence with regard to state resulting from first decision.

5. What is multistage graph? Give example. . (NOV 2016)

 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.
 G is usually assumed to be a weighted graph. In this graph, cost of an edge (i, j) is
represented by c(i, j). Hence, the cost of path from source s to sink t is the sum of costs of
each edges in this path.
 The multistage graph problem is finding the path with minimum cost from source s to
sink t.
6. What are the drawback of dynamic programming?( NOV 2015)
 Time and space requirements are high, since storage is needed for all level
 Optimality should be checked at all levels.

7. Write the applications of travelling salesman problem.( NOV 2015)


List any two application of travelling Salesman problem. (NOV 2014)

 An old application of the TSP is to schedule the collection of coins from payphones
throughout a given region
 To find shortest routes through selections of airports in the world
 solver to construct radiation hybrid maps as part of their ongoing work in genome
sequencing.

8. Give an example of dynamic programming problem. (April 2014)

Example of dynamic programming are

 Matrix Chain Multiplication


 Longest Common Subsequence
 Travelling Salesman Problem
 Knapsack problem

The solution to the knapsack problem can be viewed as a result of sequence of


decisions. We have to decide the value of xi for 1<i<n. First we make a decision on x1 and
then on x2 and so on. An optimal sequence of decisions maximizes the object function

ADDITIONAL:

9. What is optimal binary search tree?


o For a given set of identifiers different binary search tree can be created .Each binary
search treee have different performance characteristics.
o The optimal binary search tree for the identifiers set for (a 1,a2,.........an)is a binary
search tree with minimum cost.
o To construct an optimal binary search tree,define a cost function for the binary search
tree.
o To define the cost function,add fictious(imaginary) node in the place of every empty
subtree in binary search tree(BST).
o These imaginary nodes are called external nodes(drawn as squares)and all other
nodes are called internal nodes(represented as circle).
o If the BST represent n identifiers then there will be exactly n initial nodes and (n+1)
external nodes.
o Every internal nodes represent a point where a successible search may be
terminated.Every external node represent a point an unsuccessible search may
be terminated.

10. Define ‘ all pair shortest path’ problem


o Let G=(V,E) is a directed graph where E is the set of edges and V is the set of
vertices .Each edge has been associated with non negative weight .
o The objective of the problem is to calculate the length of the shortest path between
each pair of vertices
o Suppose the vertex of the graph G are numbered from 1 to n and the cost of <i,j> is
the length of the edge between i and j.
 cost[i,j]=0 where i=1 to n
 cost[i,j]=given weight,if edge exists between i and j
 cost[i,j]=∞,if edge does not exist between i and j
11. Define ‘transitive closure’
 Transitive closure is used to check whether the graph is connected or not.
 A graph is said to be connected(undirected graph) or strongly connected (directed
graph)if there is no zero in the transitive closure of the graph.
 T(c)=1 if there is a path between the vertices i and j
 if there is no path between the vertices i and j
12.Define Travelling Salesman problem(TSP).
o Let G=(V,E) be a directed graph with edge cost C ij,where Cij>0 for all i,j.
o Cij =∞ if the edge between <i,j>not belongs to E.
o The travelling salesman problem is to find tour with minimum cost (optimal tour).
o The cost of the tour is the sum of the cost of the edges on that tour.

Unit-4

Part-A

1.Define backtracking.( APRIL 2016)

Backtracking is a general algorithm for finding all (or some) solutions to some


computational problems, notably constraint satisfaction problems, that incrementally builds
candidates to the solutions, and abandons each partial candidate ("backtracks") as soon as it
determines that the candidate cannot possibly be completed to a valid solution
Advantages
The major advantage of this method is, once we know that a partial vector (x 1,…xi)
will not lead to an optimal solution that (m i+1………..mn) possible test vectors may be ignored
entirely

2. What is n-queen problem? (April 2014)


The N-queen problem is to place N-queens in N×N chessboard (matrix) in such a way that
the no two queens attack with each other in column, diagnol and rowise (ie)No two queens are in
same row,column and diagnol.

3.Define Hamiltonian cycle. (APRIL 2016)

What is Hamiltonian cycle? ( APRIL 2015)

 Let G=(V,E) be a connected graph with ‘n’ vertices.


 A Hamiltonian Cycle is a round trip path along ‘n’ edges of G that visits every vertex once
and returns to its starting position.
 If the Hamiltonian cycle begins at some vertex V 1 belongs to G and the vertices of G are
visited in the order of V 1,V2…….Vn+1,then the edges (Vi,Vi+1) are in E,1<=i<=n and the V i
are distinct except V1 and Vn+1 which are equal.
 Consider an example graph G1.:
Example

 Consider an example graph G1.:

1 2 3 4

8 7 6 5

The graph G1 has following Hamiltonian cycles:

Cycle1:1,3,4,5,6,7,8,2,1

Cycle2:1,2,8,7,6,5,4,3,1.

 Consider an another example graph G2:

1 2 3

5 4

4.What is least cost search? .( APRIL 2016)


A search strategy that uses a cost function ĉ (x) = f (h (x)) + ĝ(x) to select the next E-node would
always choose for its next E-node a live node with least ĉ (.). Hence such a search strategy is called
an LC – search.

5.Give the use of graph coloring. (NOV 2016)

 Scheduling
 Register allocation
 Pattern Matching

6. What is main objective of 0/1 knapsack problem? ( APRIL 2015)

The objective of the knapsack problem is to fill the knapsack with capacity ’m’ by including or
excluding full amounts of different n objectsin which summation of weight of the object must be less
than or equal to the capacity of the knapsack ‘m' and summation of profit of the object must be
maximum

n
Maximize ∑ pixi
i=1

n
Subject to ∑ wixi<= m
i=1

xi ϵ {0,1}

where 1<=i<=n

7.Give the implicit and explicit constraint for 8 queen problem. ( NOV 2015)

Explicit Constraints:

Si ={1,2,3,4,5,6,7,8},1  i  8
xiєSi
Solution space consist of 88 tuples.
Implicit Constraints:
i. No 2 xi’s can be the same.
i.e)All queens must be on different columns and diagonals
From the implicit constraints,
All solutions are permutations of the 8 tuple.It reduces the size of the solution space from
88 tuples to 8! tuples.

6.Define chromatic number of the graph. ( NOV 2015)


The graph G can be colored using the smallest integer ‘m’. This integer is referred to as chromatic
number of the graph. If ‘d’ is the degree of the given graph, then it can be colored with d+1 colors
that is m=d+1

7.What is an articulation point in graph? (April 2014)

A vertex ‘v’ in a connected graph ‘G’ is an articulation point, iff the deletion of vertex v together with
all vertices incident to v disconnects the graph into 2 or more
non empty components.

8.What are the requirements that are needed for performing backtracking(April 2014)

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.

Explicit Constraints:
 Explicit constraints are rules that restrict each Xi to take values only from a given set.
 All tupules that satisfy the explicit constraint define a possible solution space for I. 

Implicit constraints:
The implicit constraint determines which of the tuples in the solution space I can actually
satisfy the criterion functions.

ADDITIONAL:

9. Define explicit and Implicit constraint

Explicit Constraints:
 Explicit constraints are rules that restrict each Xi to take values only from a given set.
 All tuples that satisfy the explicit constraint define a possible solution space for I. 

Example

xi ¿ 0 or Si ={all non-negative real nos.}

xi = 0 or 1 or Si={0,1}.

li ¿ xi ¿ ui or Si={a : li ¿ a ¿ ui }

Implicit constraints:
The implicit constraint determines which of the tuples in the solution space I can actually
satisfy the criterion functions.

10.What is sum of subset problem?

We are given ‘n’ positive numbers called weights and we have to find all
combinations of these numbers whose sum is M. This is called as sum of subsets problem
.
11.What is graph coloring problem?

Let ‘G’ be a graph and ‘m’ be a given positive integer. If the nodes of ‘G’ can be
colored in such a way that no two adjacent nodes have the same color. Yet only ‘M’ colors
are used. So it’s called M-color ability decision problem.

12.What is implicit and explicit constraints of sum of subset problem?

Explicit Constraints:
xi є Si={0,1}

Implicit Constraints:
k n k
Bk(x1,x2,….xn)=true iff ∑ wixi + ∑ ≥ m and ∑ wixi + wk+1 ≤ m
i=1 i=k+1 i=1

13.What is implicit and explicit constraints of graph coloring problem?

Explicit Constraints:
 The graph G can be colored using the smallest integer ‘m’. This integer is referred to
as chromatic number of the graph.
 If ‘d’ is the degree of the given graph, then it can be colored with d+1 colors.

xi є Si={1,2,3,.. m colors}
Implicit Constraints:
The two adjacent nodes should not have same color

14.What is implicit and explicit constraints of Hamiltonian cycle?

Explicit Constraints:

Let G=(V,E) be a connected graph with ‘n’ vertices. A Hamiltonian Cycle is a round trip path
along ‘n’ edges of G that visits every vertex once and returns to its starting position.

xi є Si={set of vertices Vi in G}

Implicit Constraints:
 Each vertices should be visited only once.
 Every vertex I G must be visited
 There must be a path between the vertex n to vertex 1

15.What is chromatic number of the graph?

The graph G can be colored using the smallest integer ‘m’. This integer is referred to
as chromatic number of the graph. If ‘d’ is the degree of the given graph, then it can be
colored with d+1 colors that is m=d+1
16.How do you check if two queens are in same column?

The function, which is used to check two queens are in same column is [i=,x(j)] which
gives position of the ith queen, where i represents the row and x (j) represents the column
position.

17.How do you check if two queens are in same diagonal?

To check no two queens are in same diagonal.


Consider two dimensional array a[1:n,1:n] in which we observe that every element
on the same diagonal that runs from upper left to lower right has the same row-column
value.
Ex:

a[3,1],a[4,2],a[5,3],a[6,4],a[7,5],a[8,4]

All these squares have same row – column value .i.e)2

Also, every element on the same diagonal that runs from upper right to lower left
has the same row + column value.

Ex: a[2,6], a[3,5],a[4,4],a[5,3],a[6,2],a[7,1]

All these squares have same row + column value .i.e)8

Suppose two queens are in same position (i,j) and (k,l) then two queens lie on the
same diagonal , if and only if |j-l|=|i-k|.

18. What is planner?


 A graph is said to be planar iff it can be drawn on plane in such a way that
no two edges cross each other.
 Suppose we are given a map then, we have to convert it into planar.
Consider each and every region as a node. If two regions are adjacent then
the corresponding nodes are joined by an edge.

Consider a map with five regions and its graph


1 is adjacent to 2, 3, 4.
2 is adjacent to 1, 3, 4, 5
3 is adjacent to 1, 2, 4
4 is adjacent to 1, 2, 3, 5
5 is adjacent to 2, 4

2 3

5 4

19. What is Articulation Point and biconnected graph

Articulation Point
A vertex ‘v’ in a connected graph ‘G’ is an articulation point, iff the deletion of vertex v together with
all vertices incident to v disconnects the graph into 2 or more
non empty components.
Biconnected Graph:
A graph ‘G’ is biconnected, iff it contains no articulation points.

20.Differentiate decision problem and optimization problem\

Any problem for which the answer is either zero or one is called decision problem Any
problem that involves the identification of an optimal (maximum or minimum) value of a
given cost function is called optimization problem

21.What is deterministic and non-deterministic algorithm?

Deterministic Algorithm:
The result(outcome)of the operation in the algorithm is uniquely defined with
in the algorithm
Non Deterministic Algorithm:
The outcomes of the operation in the algorithm are not uniquely defined but
are limited to specific set of possibilities
Unit-5

Part-A

1.What is meant by NP Hard problems.( APRIL 2016)

 P is set of all decision problems solvable by deterministic algorithms in


polynomial time.
 NP is set of all decision problems solvable by non deterministic algorithms in
polynomial time.

 Problem L is NP-Hard if and only if satisfiability reduces to L.


 A Problem L is NP-Complete if and only if L is NP-Hard and L belongs to NP.

2. Define NP problem.(APRIL 2015)

 P is set of all decision problems solvable by deterministic algorithms in


polynomial time.
 NP is set of all decision problems solvable by non deterministic algorithms in
polynomial time.

 Problem L is NP-Hard if and only if satisfiability reduces to L.


 A Problem L is NP-Complete if and only if L is NP-Hard and L belongs to NP.

4.Define branch and bound. (NOV 2016)


What is branch and bound method? (NOV 2014)
A branch and bound method searches a state space tree using any search mechanism in
which all the children of the E-node are generated before another node becomes the E-
node. We assume that each answer node x has a cost c(x) associated with it and that a
minimum-cost answer node is to be found. Three common search strategies are FIFO, LIFO,
and LC.

 Used to find optimal solution to many optimization problems, especially in discrete and
combinatorial optimization
 Systematic enumeration of all candidate solutions, discarding large subsets of fruitless
candidates by using upper and lower estimated bounds of quantity being optimized
 Branch and Bound solve these problems relatively quickly

.5.Control abstractions for LC search. . (NOV 2016)

A search strategy that uses a cost function ĉ (x) = f (h (x)) + ĝ(x) to select the next E-node
would always choose for its next E-node a live node with least ĉ (.). Hence such a search
strategy is called an LC – search.

6.What is complete graph? (APRIL 2015)

A complete graph is a graph in which each pair ofgraph vertices is connected by an edge.


Thecomplete graph with graph vertices is denoted and has (the triangular numbers) undirected
edges, where is a binomial coefficient. In older literature, complete graphs are sometimes called
universal graphs.
7.Give an example of NP complete.(APRIL 2015)

 P is set of all decision problems solvable by deterministic algorithms in polynomial time.


 NP is set of all decision problems solvable by non deterministic algorithms in
polynomial time.
 A Problem L is NP-Complete if and only if L is NP-Hard and L belongs to NP.

8.What is meant by 0/1 knapsack problem? (NOV 2014

o It is similar to the fractional knapsack problem but the only difference is,
o In fractional knapsack we can also take fraction of object (part of object)to fill the
o knapsack.
o In 0/1 knapsack either the object will fully be placed(x i=1) or the object is not placed
at
o all(xi=0).
o If n objects are given with weight wi and profit pi where i=1 to n and capacity of the
knapsack 'm' is also given.
o The objective of the problem is to fill the knapsack with the help of the given object
and the resulting profit must be maximum.

Formally the problem can be stated as

maximize -∑ pi xi 1<=i<=n

subject to ∑wi xi 1<=i<=n

xi Є {0,1}.

9.What is meant by class NP-NP complete problem? (April 2014)

 P is set of all decision problems solvable by deterministic algorithms in polynomial


time.
 NP is set of all decision problems solvable by non-deterministic algorithms in
polynomial time.

 Problem L is NP-Hard if and only if satisfiability reduces to L.


 A Problem L is NP-Complete if and only if L is NP-Hard and L belongs to NP.

10.Define Clique(April 2014)

Definition: - In Clique, every vertex is directly connected to another vertex, and the
number of vertices in the Clique represents the Size of Clique.

CLIQUE COVER: - Given a graph G and an integer k, can we find k subsets of


verticesV1, V2...VK, such that UiVi = V, and that each Vi is a clique of G.

The following figure shows a graph that has a clique cover of size 3.
ADDITIONAL:

11. What is assignment problem?

Assignment problem is a special type of linear programming problem which deals with the


allocation of the various resources to the various activities on one to one basis. It does it in such a way
that the cost or time involved in the process is minimum and profit or sale is maximum.

12.What is 8 Puzzle Problem?

 8 Puzzle Problem. The 8 puzzle consists of eight numbered, movable tiles set in a 3x3 frame.
 One cell of the frame is always empty thus making it possible to move an adjacent numbered
tile into the empty cell.
 The objective is to place the numbers on tiles to match final configuration using the empty
space.
 We can slide four adjacent (left, right, above and below) tiles into the empty space. Such
a puzzle is illustrated in following diagram.
 We have discussed following solutions

12.What is Travelling salesman Problem?


Given a set of cities and distance between every pair of cities, the Travelling sales man problem(TSP)
is to find the shortest possible tour that visits every city exactly once and returns to the starting point.
For example, consider the graph shown in figure on right side. A TSP tour in the graph is 0-1-3-2-0.
The cost of the tour is 10+25+30+15 which is 80.
13. Define maximization problem, minimization problem
 In cases of a maximization problem, an upper bound tells us the maximum possible solution
if we follow the given node. For example in 0/1 knapsack we used Greedy approach to find an
upper bound.

 In cases of a minimization problem, a lower bound tells us the minimum possible solution if
we follow the given node. For example, in Job Assignment Problem, we get a lower bound by
assigning least cost job to a worker.

14. What is bounding in Branch and bound?


A branch and bound method searches a state space tree using any search mechanism in
which all the children of the E-node are generated before another node becomes the E-
node. We assume that each answer node x has a cost c(x) associated with it and that a
minimum-cost answer node is to be found. Three common search strategies are FIFO, LIFO,
and LC.
The three search methods differ only in the selection rule used to obtain the next E-node. A
good bounding helps to prune efficiently the tree, leading to a faster exploration of the
solution space. A cost function c(.) such that c( x ) < c(x) is used to provide lower bounds on
solutions obtainable from any node x. If upper is an upper bound on the cost of a minimum-
cost solution, then all live nodes x with c(x) > c( x ) > upper. The starting value for upper can
be obtained by some heuristic or can be set to  ..

5.What is pruning?
Pruning is a technique in search algorithms that reduces the size of decision trees by
removing sections of the tree that provide little power to classify instances. Pruning reduces
the complexity of the final classifier, and hence improves predictive accuracy by the
reduction of overfitting.

You might also like