Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following computational problems on an array of integers (of size n

ID: 3831547 • Letter: C

Question

Consider the following computational problems on an array of integers (of size n). Write down the running time for each problem using O-notation. Answer choices are: O(1), O(n), O(log n), O(n log n), O(n^2). No or justification is needed. Calculate the average of the values in the array ____ Sort the array using Quick sort (worst case) ____ Sort the array using Bubble sort (best case) ____ Find a value using binary search (array sorted, best case) ____ Find a value using binary search (array sorted, worst case) ____

Explanation / Answer

1. Calculate the average of the values in the array:- O(n)

2. Sort the array using quick sort(worst case) :- O(n2)

3. Sort the array using bubble sort(best case) :- O(n)

4. Find a value using binary search(array sorted, best case):- O(1)

5. Find a value using binary search(array sorted, worst case):- O(log n)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote