Professional Documents
Culture Documents
Assignment-3 1 November 2020: P (X) Anxn + An 1xn 1 + - . - + A1x + A0 (, Design A Linear Algorithm For This
Assignment-3 1 November 2020: P (X) Anxn + An 1xn 1 + - . - + A1x + A0 (, Design A Linear Algorithm For This
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?