Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is a snippet of code that relies on three methods: execA, execB, and exec. The worst, best, and average time complexity is given for

image text in transcribed

Below is a snippet of code that relies on three methods: execA, execB, and exec. 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); break; // O(n), Omega(log n), Thetan) case 5: execB(n); break; // O(n), Omega(n), Theta(n) default: exec(n); // O(n), Omega(n), 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

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

=+ (b) Show that log2 n + log2 log, log, n is an inner boundary.

Answered: 1 week ago

Question

is float a data type in java script

Answered: 1 week ago

Question

Explain the pages in white the expert taxes

Answered: 1 week ago

Question

6. Does your speech have a clear and logical structure?

Answered: 1 week ago