Write a function that will take a vector of int values

Assignment Help Computer Engineering
Reference no: EM132096033

Please help with this gomework question.

Consider the problem of finding the pairs of integers in an input list that sum to 0. Assume that the integers are distinct. This problem is easily solved in quadratic time by doing a brute-force implementation with two (nested) loops that examines all possible pairs.

Write a function that will take a vector of int values as argument and it will return the pairs of values in that vector that sum to 0. Write a brute-forced implementation as described above.

The main program has been written for you, you just have to write the code for the findPairs function.

#include <vector>

#include <iostream>

#include <sstream>

#include <chrono>

using namespace std;

vector <string> findPairs(vector<int> numbers){

}

int main(){

//create test vector to pass to the function

vector <int> testNumbers;

testNumbers.push_back(1);

testNumbers.push_back(54);

testNumbers.push_back(2);

testNumbers.push_back(-3);

testNumbers.push_back(-2);

testNumbers.push_back(58);

testNumbers.push_back(-54);

testNumbers.push_back(58);

testNumbers.push_back(68);

testNumbers.push_back(78);

testNumbers.push_back(-75);

testNumbers.push_back(-1);

//call the function

vector <string> pairs = findPairs(testNumbers);

//display results

for(int i=0;i<pairs.size(); ++i)

cout<<pairs[i]<<endl;

}

Reference no: EM132096033

Questions Cloud

Linear relation among air temperature : How do I determine if there is a linear relation among air temperature x1?, wind speed x2?, and wind chill y from the data shown below
Determine the? p-value of hypothesis test : The data below represents the population of a certain country every 10 years for the years? 1900-2000. How do I determine the? least-squares regression?
Develop a web-based pothole tracking and repair system : Why is it that many software developers don't pay enough attention to requirements engineering? Are there ever circumstances where you can skip it?
Develop a method with java program : Develop a method with java program. Write a main method to test your method.
Write a function that will take a vector of int values : Write a function that will take a vector of int values as argument and it will return the pairs of values in that vector that sum to 0.
Interval about slope of true? least-squares regression : How would I construct a? 95% confidence interval about the slope of the true? least-squares regression line shoeing the Lower and Upper Bound?
Evidence of a problem in the area : Was it evidence of a problem in the area, or was it a chance? Can you verify this? Would Binomial or Poisson distribution be suitable for modeling this case?
Identify the rows who destination network has any chance : Identify the rows who destination network has any chance of matching the IP address (compare the first three octets)
Can you explain confidence interval to me : Can you explain confidence interval to me? For example: when someone is asking what is the 95% CI for age range in a sample.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Compare the various types of human memory

As a software engineer, you have been asked to write a paper that describes the use of current technologies with regard to the human-computer interface. Explain haptic feedback, describe its key uses, and explain why it is needed

  Explain your experience installing the microsoft office

write a short paragraph in which youquestion 1 describe your experience installing the microsoft office suite software.

  Transmitting the rtp stream

Consider that a sender transmits a silence suppressed the RTP stream of G.711 audio to the receiver (G.711 refers to the name of standard for 64Kbps PCM we discussed in class).

  Define alexandra intended to make billy

What can be determined from the facts as presented about whether Alexandra intended to make Billy

  Demonstrates primary manner in which health care industry

Provide at least one example that demonstrates the primary manner in which the health care industry could implement arrays and records (structs).

  Explain why a traditional relational database

ITECH 2201 Cloud Computing - Briefly explain why a traditional relational database (RDBS) is not effectively used to store big data?

  Define issues involve in protecting organization information

Discuss the issues involved in protecting all of the organization's information. How might an organization notify its users that all communications are being.

  What it is role is in the overall program

Improve the program's functionality by utilizing at least 5 of the concepts from the list below. Document how the game works, including how you utilized each of the chosen concepts and what it's role is in the overall program.

  Why are the all ones and all zeroes subnets not used

Subnet the class C network addresses 198.67.25.0 into eight subnets. Why are the 'all ones' and 'all zeroes' subnets not used?

  Describe pipelining

Describe pipelining and how it increases the execution speed of a program.

  Derive a generating function for the sequence

Let t_n be to of ways to tile an 2 times n array with 1 times 2 tiles and 2 times. Derive a recurrence for t_n. Derive a generating function for the sequence.

  How can ms-isac help state and local governments

Does MS-ISAC Reduce Risks? Answer the following: Is there a benefit to working with MS-ISAC, How can MS-ISAC help state and local governments.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd