CS3 – ZyBook Chapter 11 & Video Lecture 3 (Solution)

$ 24.99
Category:

Description

Assignment 4
You are given a list of numbers:
[28, 22, 7, 2, 8, 14, 24, 56]
Your task is to find the longest sub-set of this list, such that all of the items in the subset can be taken as pairs where the larger value of the pair is perfectly divisible by the smaller. For example, in the above list there is a sub-set {8, 2, 24}. This sub-set satisfies the “divisibility requirement” because all the pairings demonstrate perfect divisibility: 8/2 = 4, 24/8 = 3, and 24/2 = 12. However {8, 2, 24} is not the longest sub-list that can be found that satisfies the divisibility requirement. That would be: {7, 14, 28, 56}. Actually, there are multiple possible answers. Another would be: {2, 14, 28, 56}.
Write a program that finds the longest and “pair-wise divisible” sub-set of a given list of numbers. You should implement the following functions:
vector<int> largest_divisible_pairs(vector<int> input); string vec_to_string(vector<int> v);
Pro-Tip: Using recursion to solve this problem is a good strategy.
Sample Output:
user@machine:solution$ ./ldp Input: [28 22 7 2 8 14 24 56]
Answer: [56 14 7 28]
Submission: Your program will be submitted using canvas and git + github.
2) Your repository on github.com should be private and you should add my account as a collaborator by going to “settings” → “manage access” → “invite collaborator” and entering my username:
fmresearchnovak
3) On canvas you should upload a link to this github repository
https://github.com/fmresearchnovak/HW4.git
ZyBook Chapter 11 & Video Lecture 3

Reviews

There are no reviews yet.

Be the first to review “CS3 – ZyBook Chapter 11 & Video Lecture 3 (Solution)”

Your email address will not be published. Required fields are marked *