Starting from:

$29.99

Lab 10 - Map & HashTable Problems

Lab 10 - Map & HashTable Problems
Direction: Submit typed work in the Labs directory of your github repositor or dropbox, or upload to the google classroom
assignment. Each part will have a template file provided named ''lab10A.cpp'' and ''lab10B.cpp'' respectively. Submit your
modifications of the templates. Including any additional libraries will result in a 0.
Part A: In class
Your objective is to write the definition of the function DuplicateSum() whose header is
int DuplicateSum(Vector<int>& data)
It returns the sum of all the values in data that are repeated. For instance, if data equals [1, 2, 2, 3, 2, 4, 1], the function
will return 3 (1 + 2).
Part B: Take home
Your objective is to write the definition of the function TwoSum() whose header is
bool TwoSum(Vector<ulong>& data,ulong target)
Given that target is less than 1000, the function returns true if there exists two elements of data whose values sum to
target in a linear Big-O runtime. If target is greater than or equal to 1000, data has at most 1 element, or there are no
two elements in data whose values sum to target, the function returns false.

More products