Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 12 Exercise 1: Provide an implementation of the maximum function whose declaration is shown below. The only argument of the function is a vector

image text in transcribed

Problem 12 Exercise 1: Provide an implementation of the maximum function whose declaration is shown below. The only argument of the function is a vector v of int. The function returns the largest int that is in the vector v. int maximum (const vector & v) Exercise 2: Provide an implementation of the appendVector function whose declaration is shown below. Both arguments of the function are vectors of int. The function should modify vector v by appending to it all the elements of W. For example, if v-4, 2, 5) and w= (11, 3), then v will become (4, 2, 5, 11, 3) as a result of calling the function. Hint: the vector class has a function called push back that appends values passed into it. void appendectorvctorint> & v, const vectorint> & w); Exercise 4: Implement a function that takes an integer as its sole argument and returns a vector containing the prime factors of that number. For example, if you pass in 100, then function returns the vector (2, 2, 5, 5). The function signature should look like the following vector int> factor(int n) Exercise 5: Suppose a vector v contains a sequence of integers ordered from lowest to highest. For example, v might contain the values 3, 6, 7, 12. Write a function called insert that takes this vector v as a first argument and an integer k as the second argument. The function inserts k into the vector so that it preserves the order of elements. For example, if v were (3, 6, 7, 12) and k were 5, then after calling the function, v would be (3, 5, 6,7,12) In your implementation of insert, do not use the insert function of the vector class (v.insert)

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

Step: 3

blur-text-image

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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

Discuss the states of accounting

Answered: 1 week ago