# Assignment 3 . ```Assignment 3
Due Friday of Week 14. Drop a hard copy in MailBox 75.
Question 1. (50%)
(a) Give an O(n) time algorithm to find the longest increasing contiguous
subsequence of a sequence of n numbers. (Assume that each integer
appears once in the input sequence of n numbers) For example,
A=9,3,5,8,1, 10, 13, where 3,5,8 is a contiguous subsequence, but 3,5,8,
10, is not a contiguous subsequence.
(b) Given a sequence of n real numbers A(1) ... A(n), where each A(i) can
be positive, negative or zero, design an algorithm with running time better
than the naive O(n2) time approach to determine a contiguous subsequence
A(i) ... A(j) for which the sum of elements in the subsequence is
maximized. What is the running time of your algorithm?
Question 2. (40%)
You are going to drive from Princeton to Palo Alto along a fixed route.
There are n gas stations along the route. The locations of the n stations are
given as x1=0, x2, …, xn, where xi &gt;0 is a real number indicating the
distance between the starting place (Princeton) and the i-th station. When
the fuel tank is full, the car can go to C distance. The price of the fuel at the
i-th station is Ci for the whole tank. Each time, when you stop at a station,
you have to fulfil the tank. If the remaining oil at that time is y, say y=51%,
then you have to pay (1-y)Ci at the i-th station. The fuel required from the
i-th station to the (i+1)-th station is (xi+1-xi)/C. When you start, the fuel
tank is full. When you arrive the destination (the n-th station), you also
have to add fuel so that the tank is full. Design an efficient algorithm to
compute a set of stations along the route to get the fuel so that the total cost
of the fuel you pay is minimized.
Question 3. Name two NP-complete problems. (10%)
1
```