Sei sulla pagina 1di 9

CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

DHANALAKSHMI COLLEGE OF ENGINEERING


Tambaram, Chennai

Department of Computer Science and Engineering

CS8451 – Design and Analysis of Algorithms


Year / Sem : II / IV
2 Marks Q & A

Department of Computer Science and Engineering Page 1


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

UNIT- 1
INTRODUCTION
PART A

1. What is meant by algorithmic? [A/M  14]


Algorithmic is the study of algorithms. It is more than a branch of computer science. It is the
core of computer science. It is said to be relevant to most of science, business and
technology.

2. What is an algorithm? [M/J  12]


An algorithm is a sequence of unambiguous instructions for solving a problem. It must
obtain a required output for any legitimate input in finite amount of time.

3. Give the diagrammatic representation of notion of an algorithm. [A/M  15]

Problem

Algorithm

Input Computer Output

4. What is the formula used in Euclid’s algorithm for finding the Greatest Common
Divisor of two numbers? [A/M  17]
Formula used in Euclid‟s algorithm for finding the Greatest Common Divisor of two numbers
a) GCD(m, n) = GCD(n, m mod n) until m mod n is equal to 0, since GCD(m, 0) = m.
b) It is based on repeatedly applying the equality.

5. What are the three different algorithms used to find the Greatest Common Divisor of
two numbers? [M/J  15]
Three algorithms used to find the Greatest Common Divisor of two numbers
a) Euclid‟s algorithm
b) Consecutive integer checking algorithm
c) Middle school procedure

6. What is meant by algorithm design technique? [A/M  13]


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

Department of Computer Science and Engineering Page 2


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

7. What are the two types of algorithm efficiencies? [N/D  13]


Two types of algorithm efficiencies
a) Time efficiency: Indicates how fast the algorithm runs
b) Space efficiency: Indicates how much extra memory the algorithm needs

8. What are the fundamental steps involved in algorithmic problem solving? [A/M  12]
Steps involved in algorithmic problem solving
a) Understanding the problem e) Algorithm design techniques
b) Determine the capabilities of f) Methods for specifying the
computational device algorithm
c) Choose between exact and g) Proving an algorithm‟s
approximate problem solving correctness
d) Decide on appropriate data h) Analyzing an algorithm
structures i) Coding an algorithm

9. What is meant by Pseudocode? [A/M  13]


A Pseudocode is a mixture of a natural language and programming language. It is usually
more precise than natural language. It is used to specify an algorithm.
Example:
if “1”
print “I am in case 1”
if “2”
print “I am in case 2”

10. Mention some of the important problem types in algorithms. [N/D  13]
Important problem types
a) Sorting e) Combinatorial problems
b) Searching f) Geometric problems
c) String processing g) Numerical problems
d) Graph problems

11. What are the two classical geometric problems?


Two classical geometric problems
a) Closest Pair Problem
b) Convex-Hull Problem

12. What are the steps involved in the analysis of framework?


Steps involved in the analysis of framework
a) Measuring the input‟s size
b) Specifying unit for measuring running time
c) Determine the order of growth
d) Compute worst-case, best-case and average-case efficiencies

13. What is the basic operation of an algorithm?


The basic operation of an algorithm is the operation that consumes most of the total
running time. It is usually the most time consuming operation in the algorithm‟s innermost
loop.
Department of Computer Science and Engineering Page 3
CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

14. What is meant by worst-case efficiency?


The worst-case efficiency is a time complexity when an algorithm runs for a longer time.
In Linear Search, the presence of search element in the last position is an example of
worst-case efficiency.

15. What is the running time of a program implementing the algorithm?


The running time T(n) of a program implementing the algorithm is given by the following
formula T(n) ≈ Cop x C(n), where
Cop = Time of execution of an algorithm‟s basic operation on a particular computer
C(n) = The number of times the basic operation needs to be executed

16. What is meant by best-case efficiency?


The best-case efficiency is a time complexity when an algorithm runs for short time.
In Linear Search, the presence of search element in the first position is an example of
best-case efficiency.

17. When is a function said to be in O-notation?


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

It is denoted by f(n) ε O(g(n)).

18. When is a function said to be in Ω-notation?


A function f(n) is said to be in Ω(g(n)), if f(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 non-negative
integer n0 such that f(n) >= c x g(n) for all n >=n0.

It is denoted by f(n) ε Ω(g(n)).

Department of Computer Science and Engineering Page 4


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

19. When is a function said to be in θ-notation?


A function f(n) is said to be in θ(g(n)), if f(n) is bounded both above and below by some
constant multiple of g(n) for all large n, i.e., if there exists some positive constants c1, c2
and some non-negative integer n0 such that c2 x g(n) <= f(n) <= c1 x g(n) for all n >= n0.

It is denoted by f(n) ε θ(g(n)).

20. What are the basic asymptotic efficiency classes?


Basic asymptotic efficiency classes

Class Name Class Name


2
1 Constant n Quadratic
log n Logarithmic n3 Cubic
N Linear 2n Exponential
n log n Linearithmic n! Factorial

21. What is meant by algorithm visualization?


Algorithm visualization is a technique in which images or animations are used to convey
the useful information about algorithm.

22. What are the two variations of algorithm visualization?


Variations of algorithm visualization
a) Static algorithm visualization: It shows the algorithm‟s progress through a series of still
images.
b) Dynamic algorithm visualization: It shows the algorithm‟s progress through a
continuous movie like representation.

23. What is meant by order of growth?


The order of growth is a method to find the growth of an algorithm for different values
of the input size n. It is also known as rate of growth.

24. What are the different types of substitution method?


Types of substitution method
a) Forward substitution
b) Backward substitution

Department of Computer Science and Engineering Page 5


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

UNIT- 2
BRUTE FORCE AND DIVIDE AND CONQUER
PART – A

1. Distinguish between Dynamic Programming and Divide and Conquer. [N/D  18]
S. No. Dynamic Programming Divide and Conquer
1 Many decision sequences are The problem is divided into small
generated and all the subproblems. These subproblems are
overlapping subinstances are solved independently and finally all the
considered. solutions are combined to get final
solutions.
2 It is efficient because of It is less efficient because of rework.
avoiding recomputations.
3 It uses iterative method. It uses recursive method.

2. What is meant by Hamiltonian Circuit? Give example. [N/D  18, N/D  13]
Hamiltonian Circuit/Cycle is a circuit that visits every vertex exactly once and returns to
the starting vertex.

Here, A–B–D–C–E–A is the Hamiltonian Circuit

3. What are best-case and worst-case complexities of Binary Search algorithm?


a) The best-case complexity of Binary Search algorithm is O(1).
b) The worst-case complexity of Binary Search algorithm is O(log2n)

4. Design a Brute Force algorithm for computing the value of a polynomial P(x) = a nxn
+ an-1xn-1+….+ a1x….a0 at a given point x0 and determine the steps and its
worst-case efficiency class. [A/M  15]
Algorithm Polynomial Eval
{
int sum,n,i;
write(“enter the value of n”);
Read(n);
sum=0;
write(“enter the value of x”);
Read(x);
for(i=n; i>0; i--)
{
write(“enter the coefficient”);
Read(a);

Department of Computer Science and Engineering Page 6


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

sum=sum + (a * pow(x,n));
write(“value of polynomial is”, sum);
}
}

5. Write the advantages of Insertion Sort. [N/D  17]


Advantages of Insertion Sort
a) Easy to implement
b) Compares with all individual element

6. What is meant by Closest Pair Problem? [A/M  17, M/J  16]


The Closest Pair Problem is a problem of finding two closest points from the set of n
points.
Example: In air-traffic, Closest Pair Problem is used to avoid collision between the
planes.

7. Give the general strategy for Divide and Conquer method. [M/J  16, M/J  13]
The general strategy for Divide and Conquer method is the given problem is broken into
smaller subproblems and their solutions are obtained. Later all the solutions of the
subproblems are combined to get the solution for original problem.

8. Distinguish between Linear Search and Binary Search. [N/D 14]


S. No. Linear Search Binary Search
1 Each and every element is The list is subdivided into two
compared with the key sublists. The key element is
element from the beginning searched in the sublist.
of the list.
2 Simple to implement Additional computation is required
for computing middle element.
3 Less efficient More efficient
4 For search, element need not For search, element is arranged in
be in specific order. either ascending or descending
order.

9. Give the time efficiency and drawback of Merge Sort algorithm. [N/D14]
The best-case, worst-case and average-case time efficiencies of Merge Sort algorithm are
O(n log n).
Drawbacks of Merge Sort algorithm
a) It requires extra storage to execute this method.
b) It is complicated to code.
c) It is slower than Quick Sort.

10. What is Knapsack Problem?


Knapsack Problem is the problem of picking up the most valuable objects to fill
knapsack to its capacity.

Department of Computer Science and Engineering Page 7


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

11. What is meant by Traveling Salesman Problem? [M/J  16]


The Travelling Salesman Problem is the problem of finding the shortest tour through „n‟
cities. The shortest tour visits every city exactly once and returns to the starting city.

12. Is Quick Sort a stable sorting algorithm?


No, Quick Sort is not a stable sorting algorithm because after applying this sorting
method, the ordering of similar elements is not preserved.

13. What is meant by Assignment Problem?


The Assignment Problem can be stated as follows:
a) Consider that there are „n‟ people who need to be assigned to execute „n‟ jobs i.e.,
one person is assigned to execute one job at a time.
b) Then the problem is to find such an assignment that gives the smallest total cost.
c) The cost can be computed as cost C[i, j] i.e., ith person assigned to jth job.

14. What is meant by Heap Sort? Give its complexity.


Heap Sort is a comparison based sorting technique based on Binary Heap data structure.
It is similar to Selection Sort i.e., first it finds the maximum element and places the
maximum element at the end. It repeats the same process for the remaining elements.
Heap Sort works in two stages
a) Heap construction
b) Deletion of maximum key
Time complexity of Heap Sort is O(log n).

15. What is meant by Quick Sort? Give its steps.


Quick Sort is a sorting algorithm that uses the Divide and Conquer strategy. In this
method, division is dynamically carried out.
Steps involved in Quick Sort algorithm
a) Divide and Conquer
b) Combine

16. What is meant by Closest Pair Problem? Give the Euclidean Distance formula.
The Closest Pair Problem is a problem of finding the two closest points from the set of n
points. The distance between two points pi(xi, yi) and pj(xj, yj) is denoted by Euclidean
Distance formula
d(pi, pj) = √(xi–xj)2 + (yi–yj)2 where pi and pj are two points for which i < j.

17. What is meant by Brute Force?


Brute Force is a straight forward approach to solve problems. It is directly based on the
problem‟s statement and definitions of the concepts involved.

18. What is meant by Convex-Hull Problem?


The Convex-Hull problem is a problem of finding the smallest convex polygon that
contains given n points in a plane. It can be solved by using Divide and Conquer method.

Department of Computer Science and Engineering Page 8


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

19. Name the algorithmic strategy that uses the “just do it” approach.
The Brute Force approach makes use of “just do it” approach. It is a straight forward
approach to solve problems.

20. What is meant by Exhaustive Search?


Exhaustive Search is a method in which solution is obtained by searching each element
of the given problem. It makes use of straight forward Brute Force approach.

21. What is the necessary precondition for the Binary Search?


The necessary precondition for the Binary Search is to arrange the list in ascending or
descending order.

Department of Computer Science and Engineering Page 9

Potrebbero piacerti anche