Give an algorithm with the following properties.
• Worst case running time of O(n 2 log(n)).
• Average running time of Θ(n).
• Best case running time of Ω(1).
Give an algorithm with the following properties. • Worst case running time of O(n 2 log(n))....
When sorting n records, Merge Sort has worst-case running time O(log n) O O(n log n) O O(n) O(n^2)
When sorting n records, Merge sort has worst-case running time a. O(n log n) b. O(n) c. O(log n) d. O(n^2)
For each algorithm, give a reasonable big-O bound on its worst-case running time. Omit unnecessary terms and constants in your bound, for example, don't say O(2n22n 1), say O(n2). (In most cases, these aren't the best possible algorithms for each task!) Briefly explain your reasoning in each case.
Give the best-case and worst-case running time of SELECTION SORT in Θ notation, in details and with explanation
Insertion sort on small arrays in merge sort Although merge-sort runs in Θ(n log n) worst-case time and insertion sort runs in Θ(n 2 ) worst-case time, the constant factors in insertion sort can make it faster in practice for small problem sizes on many machines. Thus, it makes sense to coarsen the leaves of the recursion by using insertion sort within merge sort when subproblems become sufficiently small. Consider a modification to merge sort in which n/k sublists of...
7. What is the worst-case running time complexity of an algorithm with the recurrence relation T(N) = 2T(N/4) + O(N2)? Hint: Use the Master Theorem.
Give an example of either iterative or recursive algorithm that has Ө( log n) running time. Give detailed time performance analysis (recurrence relation for recursive)
What is the worst-case asymptotic time complexity of the following divide-andconquer algorithm (give a Θ-bound). The input is an array A of size n. You may assume that n is a power of 2. (NOTE: It doesn’t matter what the algorithm does, just analyze its complexity). Assume that the non-recursive function call, bar(A1,A2,A3,n) has cost 3n. Show your work! Next to each statement show its cost when the algorithm is executed on an imput of size n abd give the...
What is the worst-case asymptotic time complexity of the following divide-andconquer algorithm (give a Θ-bound). The input is an array A of size n. You may assume that n is a power of 2. (NOTE: It doesn’t matter what the algorithm does, just analyze its complexity). Assume that the non-recursive function call, bar(A1,A2,A3,n) has cost 3n. Show your work! Next to each statement show its cost when the algorithm is executed on an imput of size n abd give the...
Show that the worst-case runtime of the Algorithm Heapify is on an array of length n in Ω(log(n)). Note: Construct a heap A with n nodes and show that heapify is called recursively accordingly.