Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4) For each of the following functions, determine the worst-case Big-O run time. Justify your answers. You can assume all vectors have n elements, so

image text in transcribedimage text in transcribed

4) For each of the following functions, determine the worst-case Big-O run time. Justify your answers. You can assume all vectors have n elements, so show your answers in terms of n. (Don't try to figure out what these functions do, the body of the loop is just there to give you something to look at) a. Mergesort, as defined in class (and written in the lab), but where the vector to be sorted is passed by value instead of reference. This means the return vector will be returned directly, rather than changed as a reference parameter. Recall that to pass a vector by value, you'll have to copy each element in the vector into the function. b. int f(vector& v){ for(int i = 0; i& v){ for(int i = 0; i&v){ for(int i = 0; i&v){ for(int i =1;i& v, int x){ // x is initially N if(x==0) return v[x]; else return 2*g(v,x-1); } //show the run times of all 3 functions g. int f(vector& v){ for(int i = 0; i& v, int x){ // x is initially N if(x == 0) return v[x]; else return f(v)*g(v,x-1); } int h(vector& v){ for(int i = 0; i<><><><><><>

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

please dont use chat gpt AI 5 5 7 . .

Answered: 1 week ago

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago