Find Jobs
Hire Freelancers

aj

$30-50 USD

Completed
Posted about 22 years ago

$30-50 USD

Paid on delivery
Given an integer pair p, the first integer is called [login to view URL] and the second integer is called p.second. Given a set s of integer points, the first-sum is the sum of all the first integers in the set: first-sum(s) = sum([login to view URL]) for all p in s. Similarly, the second-sum is the sum of all the second integers in the set: second-sum(s) = sum([login to view URL]) for all p in s Given a set s of integer points, the difference-sum is the absolute value of the difference between first-sum(s) and second-sum(s); that is difference-sum(s) = | first-sum(s) - second-sum(s) | for the same set s of integer pairs, the total-sum is the sum of the first and sums: total-sum(s) = first-sum(s) + second-sum(s) The Problem Write a procedure that accepts a vector of integer pairs V and an non-negative integer n and returns an n-element subset of the integer pairs S having the following properties: The difference-sum of the returned subset is among the smallest of the difference-sums of all possible n-element subsets of V. That is, if s is the returned subset, then difference-sum(s) <= difference-sum(s) for any n-element subset s' of V If s' is another n-element subset of V having the same difference sum as s, then the total sum s is no smaller than the total sum s'. That is, For any n-element subset s' of V, if difference-sum(s) == difference-sum(s'), then total-sum(s') <= total-sum(s). The prototype for your procedure should be std::vector pick_pairs( const std::vector &, unsigned n); Your procedure returns not the pairs themselves, but the indices of the input vector for the pairs in the subset. If n is greater than the input vector size, your procedure should print an error message and exit. ## Deliverables Complete the project using STL of C++ and should be fully-functional and tested for all input validations working program(s) in executable form as well as complete source code of all work done. Complete copyrights to all work purchased. ## Platform It should be compiled and tested on Sunsolaris,Unix,Linux with C++ and STL
Project ID: 2844036

About the project

5 proposals
Remote project
Active 22 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
See private message.
$21.25 USD in 14 days
5.0 (47 reviews)
4.5
4.5
5 freelancers are bidding on average $29 USD for this job
User Avatar
See private message.
$34 USD in 14 days
4.8 (44 reviews)
5.4
5.4
User Avatar
See private message.
$38.25 USD in 14 days
4.5 (42 reviews)
4.6
4.6
User Avatar
See private message.
$42.50 USD in 14 days
4.7 (48 reviews)
4.3
4.3
User Avatar
See private message.
$8.50 USD in 14 days
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
United States
5.0
5
Member since Mar 28, 2002

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.