
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Data Structures and Algorithms; Subject: Computer Science; University: Penn State - Main Campus; Term: Spring 2008;
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Due: Friday, February 6, in class or before noon on the following Saturday.
Problem 1.
You are given points p 0 , p 1 ,... , pn , and pi has coordinates x [ i ], y [ i ]. Assume that x [0] = y [0] = 0.
a. Assume that all points other than point 0 are in quadrant I ( x [ i ] > 0 and y [ i ] > 0) or in quadrant III ( x [ i ] < 0 and y [ i ] < 0). Describe how to test if p 0 is extreme in this set using O ( n ) steps.
b. Modify your test so it still uses O ( n ) steps, but it does a bit more: if p 0 is extreme, it finds neighbors of p 0 on the polyline of the convex hull of our point set (see Figure 3.5, where p 1 has neighbors: p 3 and p 6.
Problem 2.
You have array of numbers A [0],... , A [ n − 1], and target number t. Check if for some i < n /2 and j ≥ n /2 we have A [ i ] + A [ j ] = t.
a. Describe a reasonable brute force algorithm. What is the running time?
b. Using sorting and binary search, describe how to find the answer in time O ( n log n ).
Problem 6 on page 119.
I do not know how one can reduce the number of sets to consider in brute force approach. Instead, explain how problem 2 can be used to reduce the time needed to O (2 n /2) (or O ( n 2 n /2).
Problem 7 on page 119.
Additionally, explain why the clique problem has an algorithm that runs in time O (2 n /2).