Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

https://en.m.wikipedia.org/wiki/Geometric_mean Below is a snippet of code that relies on three methods: execA, execB, and execC. The worst, best, and average time complexity is given

image text in transcribed https://en.m.wikipedia.org/wiki/Geometric_mean
image text in transcribed
Below is a snippet of code that relies on three methods: execA, execB, and execC. The worst, best, and average time complexity is given for each of these functions. int exec = random.nextInt(6); switch(exec) { case 0: execA(n); // O(n*), Omega(log n), Theta(n) break; case 5: execB(n); // O(n), Omega(n), Theta(n) reak%3B default: execC(n); // O(n), Omega(n2), Theta(n*log n) } Please answer the following: 1. [2 marks] What is the worst case Big-O for this code? Justify your answer. 2. [2 marks ] What is the best case Omega? Justify your answer. 3. [1 marks] Estimate average case Theta using your answer from 1 and 2. 4. [1 mark ] For answering question 3 you probably assumed an arithmetic mean (an average you are most familiar with). However, there are different kinds of averages. One alternative average is a geometric mean and is actually better suited for non-linear functions. Estimate average case Theta again but this time using a geometric mean. If you are unfamiliar with this formula you can get it here (click). 5. [2 marks] In this example, averaging Theta using best/worst isn't the preferred choice because you can analyze this code and get an exact answer for theta. What is the real average time complexity (Theta) for this code? Justify your

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

Genomes And Databases On The Internet A Practical Guide To Functions And Applications

Authors: Paul Rangel

1st Edition

189848631X, 978-1898486312

More Books

Students also viewed these Databases questions

Question

Whaye Cheres remen -3ch bic Itatexy 121060

Answered: 1 week ago

Question

love of humour, often as a device to lighten the occasion;

Answered: 1 week ago

Question

orderliness, patience and seeing a task through;

Answered: 1 week ago

Question

well defined status and roles (class distinctions);

Answered: 1 week ago