Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (25 points) Use the STL class vector to write a C++ function that returns true if there are two elements of the vector for

image text in transcribed

1. (25 points) 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

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions