Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
UNIT- 1
INTRODUCTION
PART A
Problem
Algorithm
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
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
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
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.
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);
sum=sum + (a * pow(x,n));
write(“value of polynomial is”, sum);
}
}
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.
9. Give the time efficiency and drawback of Merge Sort algorithm. [N/D14]
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.
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.
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.