You are on page 1of 1

Assignment-3

1st November 2020


Q1: Design a brute-force algorithm for computing the value of a polynomial
p(x) = anxn + an−1xn−1 + . . . + a1x + a0
at a given point x0 and determine its worst-case efficiency class.
b. If the algorithm you designed is in Θ(n2 ¿, design a linear algorithm for this
problem.
c. Is it possible to design an algorithm with a better-than-linear efficiency for this
problem?

Q2: Consider the problem of counting, in a given text, the number of substrings
that start with an A and end with a B. For example, there are four such substrings
in CABAAXBYA.
a. Design a brute-force algorithm for this problem and determine its
efficiency class.
b. Design a more efficient algorithm for this problem.

Q3: The closest-pair problem can be posed in the 3-dimensional space, in which
the Euclidean distance between two point’s p1(x1, y1, z1) and p2(x2, y2, z2) is
defined as
D = √ (x 1−x 2)2 +( y 1− y 2)2+(z 1−z 2)2

What is the time-efficiency class of the brute-force algorithm for the 3-dimensional
closest-pair problem?

Q4: What is travelling sales problem? Solve it using brute force.

You might also like