3 Problems for Assignment 9 - Algorithms Design - Fall 2006 | CS 1510, Assignments of Computer Science

Material Type: Assignment; Class: ALGORITHM DESIGN; Subject: Computer Science; University: University of Pittsburgh; Term: Fall 2006;

Typology: Assignments

Pre 2010

Uploaded on 09/02/2009

koofers-user-kan-1
koofers-user-kan-1 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS1510 Design and Analysis of Algorithms, Fall 2006
Homework 9. Assigned on Thu Nov 8th, 2006. Due in class on Wed Nov 15th, 2006.
1. Consider the dominant element in twin arrays problem. The input to the problem is 2 sets
X and Y of numbers. Set X contains n numbers x1, x2, …,xn. Set Y contains n numbers y1, y2,
…,yn. We will assume that the numbers are distinct. An element xi of X is dominant element
if xi is greater than all elements in Y. Similarly, an element yi of Y is dominant element if yi
is greater than all elements in X. The goal is to find a dominant element in either set. For
example, suppose X={5,4,7,2} and Y={6,3,8,9}. Then 8 and 9 are dominant elements, X
contains no dominant elements. Suppose further that the only operation an algorithm can
perform is to compare an element of X with an element of Y. That is two elements from the
same set cannot be compared against one another. Devise an algorithm that solves this
problem by making at most 2n-1 comparisons.
2. Show that no algorithm solves the dominant element in twin arrays problem with fewer
than 2n-1 comparisons.
3. In the Polynomial Squaring (PSQ) problem, the input consists of a polynomial P on 1
variable with degree n-1. Note that a polynomial of degree n-1 has n coefficients. The goal
is to compute the P2. In the Polynomial Multiplication (PMULT) problem, the input
consists of two polynomials P and Q on 1 variable with degree n-1. The goal is to compute
the product P Q. Show that if there exists an algorithm for PSQ with worst-case running time
O(n), then there exists an algorithm for PMULT with worst-case running time O(n). Specific
points that you should describe are the following.
(a) The direction of the reduction.
(b) The reduction itself.
(c) The running time of the reduction.
(d) The number of times the reduction make calls to a subroutine.
(e) The size of the input passed to a subroutine in each call.
(f) The relationship of the running time of the algorithm for PSQ and that for PMULT.
1

Partial preview of the text

Download 3 Problems for Assignment 9 - Algorithms Design - Fall 2006 | CS 1510 and more Assignments Computer Science in PDF only on Docsity!

CS1510 Design and Analysis of Algorithms, Fall 2006 Homework 9. Assigned on Thu Nov 8th, 2006. Due in class on Wed Nov 15th, 2006.

  1. Consider the dominant element in twin arrays problem. The input to the problem is 2 sets X and Y of numbers. Set X contains n numbers x 1 , x 2 , …, xn. Set Y contains n numbers y 1 , y 2 , …, yn. We will assume that the numbers are distinct. An element xi of X is dominant element if xi is greater than all elements in Y. Similarly, an element yi of Y is dominant element if yi is greater than all elements in X. The goal is to find a dominant element in either set. For example, suppose X={5,4,7,2} and Y={6,3,8,9}. Then 8 and 9 are dominant elements, X contains no dominant elements. Suppose further that the only operation an algorithm can perform is to compare an element of X with an element of Y. That is two elements from the same set cannot be compared against one another. Devise an algorithm that solves this problem by making at most 2 n -1 comparisons.
  2. Show that no algorithm solves the dominant element in twin arrays problem with fewer than 2 n -1 comparisons.
  3. In the Polynomial Squaring (PSQ) problem , the input consists of a polynomial P on 1 variable with degree n -1. Note that a polynomial of degree n -1 has n coefficients. The goal is to compute the P^2. In the Polynomial Multiplication (PMULT) problem , the input consists of two polynomials P and Q on 1 variable with degree n -1. The goal is to compute the product P Q. Show that if there exists an algorithm for PSQ with worst-case running time O(n), then there exists an algorithm for PMULT with worst-case running time O(n). Specific points that you should describe are the following. (a) The direction of the reduction. (b) The reduction itself. (c) The running time of the reduction. (d) The number of times the reduction make calls to a subroutine. (e) The size of the input passed to a subroutine in each call. (f) The relationship of the running time of the algorithm for PSQ and that for PMULT. 1