0% found this document useful (0 votes)
1K views

AI & DS - AD3351 DAA - 2marks (Unit 1 & 2) Question Bank

1. The document discusses key concepts in algorithm analysis including defining an algorithm, measuring time and space complexity, and algorithm design techniques like divide and conquer and dynamic programming. 2. It also addresses measuring algorithm efficiency in terms of time and space, and analyzing worst-case, best-case, average-case, and amortized efficiency. 3. Classical geometric problems like the closest pair and convex hull problems are mentioned along with notation for analyzing asymptotic runtime and the general procedure for developing dynamic programming algorithms.

Uploaded by

DHANYA
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)
1K views

AI & DS - AD3351 DAA - 2marks (Unit 1 & 2) Question Bank

1. The document discusses key concepts in algorithm analysis including defining an algorithm, measuring time and space complexity, and algorithm design techniques like divide and conquer and dynamic programming. 2. It also addresses measuring algorithm efficiency in terms of time and space, and analyzing worst-case, best-case, average-case, and amortized efficiency. 3. Classical geometric problems like the closest pair and convex hull problems are mentioned along with notation for analyzing asymptotic runtime and the general procedure for developing dynamic programming algorithms.

Uploaded by

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

DEPARTMENT OF ARTIFICIAL INTELLIGENCE & DATA SCIENCE

AD3351 – DESIGN AND ANALYSIS OF ALGORITHM

2 MARKS (UNIT 1 & 2)

1. Define Algorithm
An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining
a required output for any legitimate input in finite amount of time.
An algorithm is step by step procedure to solve a problem.

2. Differentiate time complexity and space complexity of an algorithm


The space complexity of an algorithm is the amount of memory it needs to run to
completion. The time complexity of an algorithm is the amount of computer time it needs
to run to completion. Time efficiency is analyzed by determining the number of
repetitions of the basic operation as a function of input size.

3. How do you measure the efficiency of an algorithm?


The efficiency of an algorithm is defined with the components.
Time efficiency: indicates how fast the algorithm runs
Space efficiency: indicates how much extra memory the algorithm needs.

4. How does a divide and conquer algorithm work?


Divide and conquer is an algorithm design paradigm based on multi branched recursion. The
general plan is as follows:
1. A problems instance is divided into several smaller instances of the same problem, ideally about
the same size
DEPARTMENT OF ARTIFICIAL INTELLIGENCE & DATA SCIENCE

AD3351 – DESIGN AND ANALYSIS OF ALGORITHM

2 MARKS (UNIT 1 & 2)


2. The smaller instances are solved, typically recursively
3. If necessary the solutions obtained are combined to get the solution of the original problem
5.What is Convex Hull problem
Convex hull: The convex hull of a set S of points is the smallest convex set containing S. The
“smallest” requirement means that the convex hull of S must be a subset of any convex set
containing S.
Convex : A set of points (finite or infinite) in the plane is called convex if for any two points p and
q in the set, the entire line segment with the endpoints at p and q belongs to the set.
6.Define heap sort.
A heap can be defined as a binary tree with keys assigned to its nodes, one key per node, provided
the following two conditions are met:
1. The shape property—the binary tree is essentially complete (or simply complete), i.e., all its
levels are full except possibly the last level, where only some rightmost leaves may be missing.
2. The parental dominance or heap property—the key in each node is greater than or equal to the
keys in its children.
7. What do you mean by dynamic programming?
Dynamic programming is an algorithm design method that can be used when a solution to
the problem is viewed as the result of sequence of decisions. Dynamic programming is a
technique for solving problems with overlapping sub problems. These sub problems arise from a
recurrence relating a solution to a given problem with solutions to its smaller sub problems
only once and recording the results in a table from which the solution to the original problem
is obtained.
8. State the principle of optimality
The principle of optimality is the basic principle of dynamic programming. It states that an optimal
sequence of decisions has the property that whenever the initial stage or decisions must
constitute an optimal sequence with regard to stage resulting from the first decision.
DEPARTMENT OF ARTIFICIAL INTELLIGENCE & DATA SCIENCE

AD3351 – DESIGN AND ANALYSIS OF ALGORITHM

2 MARKS (UNIT 1 & 2)


9. Define Recursion
The process in which a function calls itself directly or indirectly is called recursion and the
corresponding function is called as recursive function. Using recursive algorithm, certain
problems can be solved quite easily.
10. Write the brute force algorithm in String Matching?
ALGORITHM BruteForceStringMatch(T [0..n − 1], P[0..m − 1])
//Implements brute-force string matching
//Input: An array T [0..n − 1] of n characters representing a text and
// an array P[0..m − 1] of m characters representing a pattern
//Output: The index of the first character in the text that starts a
// matching substring or −1 if the search is unsuccessful
for i ←0 to n − m do
j ←0
while j <mand P[j ]= T [i + j ] do
j ←j + 1
if j = m return i
return −1

11. What are algorithm design techniques?


Algorithm design techniques are general approaches to solving problems algorithmically,
applicable to a variety of problems from different areas of computing. General design techniques
are:
(i) Brute force (ii) divide and conquer (iii) decrease and conquer (iv) transform and conquer
(v) greedy technique (vi) dynamic programming (vii) backtracking (viii) branch and bound.
12. What is recurrence equation?
A recurrence is an equation or inequality that describes a function in terms of its value on smaller
inputs. Recurrences are generally used in divide-and-conquer paradigm.
A recurrence relation is an equation which represents a sequence based on some rule. It helps in
finding the subsequent term (next term) dependent upon the preceding term (previous term). If we
know the previous term in a given series, then we can easily determine the next term.
DEPARTMENT OF ARTIFICIAL INTELLIGENCE & DATA SCIENCE

AD3351 – DESIGN AND ANALYSIS OF ALGORITHM

2 MARKS (UNIT 1 & 2)


13. What is order of growth?
The order of growth of an algorithm is an approximation of the time required to run a computer
program as the input size increases. The order of growth ignores the constant factor needed for
fixed operations and focuses instead on the operations that increase proportional to input size.
14. What is presorting?
Presorting is a form of preconditioning. Preconditioning is manipulating the data to make the
algorithm faster. Another example is the problem to determine the uniqueness of array elements.
The brute force algorithm would compare each array element with the rest of the array. The cost
would be Θ(n2).
15. List the general procedure of dynamic programming?
The development of dynamic programming algorithm can be broken into a sequence of 4 steps.
• Characterize the structure of an optimal solution.
• Recursively define the value of the optimal solution.
• Compute the value of an optimal solution in the bottom-up fashion.
• Construct an optimal solution from the computed information.
16. What is meant by Feasible and optimal solution?
Given n inputs and we are required to form a subset such that it satisfies some given constraints
then such a subset is called feasible solution. A feasible solution either maximizes or minimizes
the given objective function is called as optimal solution.
17. What is pseudo code?
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.
18. What are the classical geometric problems?
The two classic geometric problems are,
1. The closest pair problem: given n points in a plane find the closest pair among them
2. The convex hull problem: find the smallest convex polygon that would include all the
points of a given set.
DEPARTMENT OF ARTIFICIAL INTELLIGENCE & DATA SCIENCE

AD3351 – DESIGN AND ANALYSIS OF ALGORITHM

2 MARKS (UNIT 1 & 2)


19. What is worst-case efficiency?
The worst-case efficiency of an algorithm is 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.
20.What is best-case efficiency?
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.
21.What is average case efficiency?
The average case efficiency of an algorithm is its efficiency for an average case input of size n. It
provides information about an algorithm behavior on a “typical” or “random” input.
22. What is amortized efficiency?
In some situations a single operation can be expensive, but the total time for the entire sequence of n
such operations is always significantly better that the worst case efficiency of that single operation
multiplied by n. this is called amortized efficiency.
23.Define notation?
A function t(n) is said to be in (g(n)), denoted by t(n) (g(n)), if t(n) is bounded below by some
constant multiple of g(n) for all large n, i.e., if there exists some positive constant c and some
nonnegative integer n0 such that
T(n) >= cg(n) for all n >=. n0
24. What is recursive algorithm?
An algorithm is said to be recursive if the same algorithm is invoked in the body. An algorithm that
calls itself is direct recursive. Algorithm A is said to be indeed recursive if it calls another algorithm,
which in turn calls A.
25. What is Algorithm Visualization?
It is defined as the use of images to convey some useful information about algorithms.
26. Define Static Algorithm Visualization?
Static Algorithm Visualization shows an algorithms progress through a series of still images.
On other hand, Algorithm animation shows a continuous movie like presentation of an algorithm’s
operation.
DEPARTMENT OF ARTIFICIAL INTELLIGENCE & DATA SCIENCE

AD3351 – DESIGN AND ANALYSIS OF ALGORITHM

2 MARKS (UNIT 1 & 2)


27. What are the steps involved in the analysis framework?
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
28. State the general principle of greedy algorithm?
Greedy method is the most important design technique, which makes a choice that looks best at
that moment. A given ‘n’ inputs are required us to obtain a subset that satisfies some constraints
that is the feasible solution. A greedy method suggests that one can device an algorithm that works in
stages considering one input at a time.
29. What is the maximum and minimum problem?
The problem is to find the maximum and minimum items in a set of ‘n’ elements. Though this
problem may look so simple as to be contrived, it allows us to demonstrate divide and conquer in
simple setting.
30. Give the recurrence relation of divide-and-conquer?
The recurrence relation is
T(n) = g(n)
T(n1) + T(n2) +---- + T(nk) + f(n)
31. 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.
32. List out the 4 steps in Strassen’s Method?
1.Divide the input matrices A and B into n/2 * n/2 submatrices, as in equation (1). 2.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.
DEPARTMENT OF ARTIFICIAL INTELLIGENCE & DATA SCIENCE

AD3351 – DESIGN AND ANALYSIS OF ALGORITHM

2 MARKS (UNIT 1 & 2)


4.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.
33. 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.
34. Define the decrease and conquer method.
Decrease & conquer is a general algorithm design strategy based on exploiting the relationship
between a solution to a given instance of a problem and a solution to a smaller instance of the same
problem. The exploitation can be either top-down (recursive) or bottom-up (nonrecursive).
35. Define the Transform-and-Conquer
The Transform and conquer technique is a way of solving problems by breaking them down into
smaller sub problems, solving the smaller sub problems, and then combining the solutions to the
sub problems to solve the original problem.

You might also like