--------------------------------------------------------- Alex. Gerbessiotis CS 610 FALL 2025 (c) All rights reserved. SEPTEMBER 2025. --------------------------------------------------------- PROBLEM 1: FALSE, TRUE, FALSE, FALSE, FALSE, FALSE. PROBLEM 2 --------- 1. O(n). It is O(lg(2^n -1 +1)) = O(n). 2. O(n^4). It is O((n^2)^2) = O(n^4). 3. (b). (a) is $\Theta(nlgn)$ by Stirling's formula and thus $nlgn = o(n^2)$ concluding (b) is asymptotically larger. 4. f(n) is asymptotically larger. 2**(4**n)= 2**(2**n x 2**n) 4**(2**n)= 2**(2 x 2**n) Thus taking limits f(n)/g(n) = 2**( 2**n (2**n -2)) -> oo However, I am going to accept as ok the misinterpretation (a) is ${16}^n$ and (b) is ${16}^n$, None; they are asymptotically equal. PROBLEM 3 --------- omega, Theta, o, omega. PROBLEM 4 --------- Merge(X1,X2,X3,X4,n,3n,n,n) 1. Y1 = X3 merge X4 ; // 2n keys in <= 2n-1 comps. 2. Y2 = Y1 merge X1 ; // 3n keys in <= 3n-1 comps. 3. Y3 = Y2 merge X2 ; // 6n keys in <= 6n-1 comps return(Y3) // 6n keys total; 11n-3 = 11n+o(n) comps total. PROBLEM 5 ---------- <3 4 5 ... n-1 n 1 2> The subsequence of length n-2 < 3 4 5 ... n-1 n> is sorted so InsertionSort would take n-3 comparisons to sort it! Then key 1 is to be inserted to the far left thus requiring n-2 comparisons for the n-2 keys of the subsequence. Then we get n-1 keys of the input sorted < 1 3 4 5 ... n-1 n> Moreover key 2 will need to be compared to all those keys and deposited to the right of 1 and left of 3. This requires n-1 comparisons. The comparison total is (n-3)+(n-2)+(n-1) = 3n - 6. ------------------------------------------------------------ Alex. Gerbessiotis CS 610 FALL 2025 (c) All rights reserved. SEPTEMBER 2025. Time Created:09/25/2025@16:01 Last Update: 10/02/2025@10:48 ------------------------------------------------------------