CSc 445: Homework Assignment 2
Assigned: Monday Feb 4 2008,
Due: 10:30 AM, Monday February 18 2008
Clear, neat and concise solutions are required in order to receive full credit. Revise your work carefully before
submission, and consider how your work is presented. If you cannot solve a particular problem, state this
clearly in your writeup, and write down only what you know to be correct. For involved proofs, ±rst outline
the argument and then delve into the details.
1. (10 pts) Let
A
be an array of
n
distinct integers. Suppose
A
has the following property: there exists an
index 1
≤
k
≤
n
such that
A
[1]
, . . ., A
[
k
] is an increasing sequence and
A
[
k
+1]
, . . ., A
[
n
] is a decreasing
sequence. Design and analyze an eFcient algorithm for ±nding
k
.
2. (10 pts) Suppose we are given an array
A
, each element of which represents a di²erent vote in the next
election, where each vote is given as an integer representing the ID of the chosen candidate. Assume
that the ID of a candidate can be a much larger number than
n
, the total number of votes and we
would like to use no more than
O
(1) additional storage. Without making any assumptions about who’s
running or even how many candidates there are, design and analyze an
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '08
 Kobourov
 Algorithms, pts, LG, Tree traversal, time algorithm

Click to edit the document details