In terms of n, what is the worst-case running time of countingSort on an input array of n letters from the alphabet (so k = 26, and n is arbitrary)?
Note: Please upvote the answer if you find it useful and comment down below for any queries.
The worst-case running time of countingSort is = O(n) because ultimately the inner loop will execute n times and k being a constant does not impact the time complexity.
In terms of n, what is the worst-case running time of countingSort on an input array...
Question 1. (1 marks) The following procedure has an input array A[1..n] with n > 2 arbitrary integers. In the pseudo-code, "return” means immediately erit the procedure and then halt. Note that the indices of array A starts at 1. NOTHING(A) 1 n = A. size 2 for i = 1 ton // i=1,2,..., n (including n) 3 for j = 1 ton // j = 1,2,...,n (including n) 4. if A[n - j +1] + j then return 5...
2. Assume you have an input array A with entries numbered 1 through n. One intuitive way to randomize A is to generate a set of n random values and then sort the array based on these arbitrary mumbers. (a) (10 pts) Write pseudocode for this PERMUTE-BY-SorTInG method (b) (10 pts) Do best-, average, and worst-case analyses for this method. (c) Extra credit (15 pts): The algorithm RANDOMIZE-In-PLACE(A) A. length for i 1 to n 1 n= 2 swap Ali...
4) [15 points total (5 points each)] Assume you are given a sorted array A of n numbers, where A is indexed from 1 up to n, anda number num which we wish to insert into A, in the proper sorted position. The function Search finds the minimum index i such that num should be inserted into Ali]. It searches the array sequentially until it finds the location i. Another function MakeRoom moves A[i], .., AIn] to Ali+1]...AIn+1] same sort...
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...
4. Big-Oh and Rune time Analysis: describe the worst case running time of the following pseudocode functions in Big-Oh notation in terms of the variable n. howing your work is not required (although showing work may allow some partial t in the case your answer is wrong-don't spend a lot of time showing your work.). You MUST choose your answer from the following (not given in any particular order), each of which could be re-used (could be the answer for...
Describe the worst case running time of the following pseudocode functions in Big-Oh notation in terms of the variable n. Show your work b) void func(int n) { for (int i = 0; i < n; i = i + 10) { for (int j = 0; j < i; ++i) { System.out.println("i = " + i); System.out.println("j = " + j);
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 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).
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)
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)