Question: Use the STL class vector to write a C++ function that returns true if there are two elements of the vector for which their

Use the STL class vector to write a C++ function that returns 







Use the STL class vector to write a C++ function that returns true if there are two elements of the vector for which their product is odd, and returns false otherwise. Provide two algorithms for solving this problem with the efficiency of O(n) for the first one and O(n) for the second one where n is the size of the vector. Justify your answer by writing the running time functions in terms of n for both the algorithms. What do you consider as an operation for each algorithm? Are the best and worst cases for both the algorithms the same in terms of Big-O notation? Justify your answer. . Describe the situations of getting the best and worst cases, give the samples of the input for each case and check if your running time functions match the number of operations.

Step by Step Solution

3.40 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets start by providing the C function and then discussing the algorithms and their efficiency inclu... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!