EC330 Applied Algorithms and Data Structures For Engineers Fall 2018 Homework 5
EC330 Applied Algorithms and Data Structures For Engineers Fall 2018 Homework 5
Fall 2018
Homework 5
This homework has a written part and a programming part. Both are due at 8:59 am on
November 5. You should submit both parts on Blackboard. For the written part, you
should submit a single PDF file containing either typeset answers or scanned copies of
hand-written answers. Make sure you write your answers clearly. For the programming
part, your code should be easy to read and understand, and demonstrate good code
design and style. Your program must compile and run on the lab computers.
1
Input: v1 = [1, 2], v2 = [3]
Output: 2
Your algorithm should have an asymptotic running time faster than 𝑂(𝑛 + 𝑚)
where 𝑛 and 𝑚 are the sizes of the two vectors.
b) [35 pt]
Implement the function maxCollinearPoints in prob4.h. Given a set of points, it
should find the maximum number of points that lie on the same line and
return this set of points. If there is more than one set, return one of them. You
may assume that all the input points are unique and there are at least two
points in the input set. You may find it useful to define lines with slopes and
y-intercepts. Below is an example input and output.
Test your code thoroughly and document your code clearly. The most
time/space efficient solution(s) will receive 5 bonus points.