--------------------------------------------------------- Alex. Gerbessiotis CS 610 FALL 2025 EXAM 2 SOLKEY (c) All rights reserved. OCTOBER 2025. --------------------------------------------------------- PROBLEM 1: FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE PROBLEM 2 PROBLEM 3 --------- --------- Part of the grade is writing down Theta,Theta,omega,omega T,C with the appropriate parameter. 1 T(n)=Theta(nlgn) PROBLEM 4 2 T(n)= O(n**2(lgn)**2) ------------ 3 T(n)=O(n) 1. Theta(n**3 ) 4 T(n)=Theta(n*lgn) 2. Theta(n! ) 3. Theta(n (lgn)**2) 4. Theta(n * lgn ) PROBLEM 5 --------- T(n) = 6nlgn - 10n. PROBLEM 6 --------- TTACG GGTTT WAACG GTTAA WTACA ASCII Bits=25*8=200bits (i.e. 25B) T=8 , A = 7 C = 3, G=5, W =2 25 / \ Huffman bits 10 \ = 2*3+3*3+5*2+7*2+8*2 = 55 bits (in 7B) / \ \ 5 \ 15 We got from 200 down to 55 bits: savings 73% / \ \ / \ (or we got from 25B down to 7B : savings 72% .) W:2 C:3 G:5 A:7 T:8 000 001 01 10 11 PROBLEM 7 -------------------------------------------------------------------- We first perform a BinarySearch of all keys of $A$ into $B$ just to count the number $d$ intersections i.e. keys $k$ such that $k \in A \cap B$. This determines the cardinality $d$ of $D$ and the space for $D$ is allocated. Obviously $d\leq n$. We repeat the BinSearch to fill $D$ with the intersection $A \cap B$. BinSearch returns a NOTFOUND(-1) or the index of the key in B that is equal to $A[i]$. To avoid a 'third' BinSearch in line 6 we store the index of the BinSearch of line 6 in variable indx; note that in line 4 we reset $d=0$ and we use it as an index of D to fill D. Inter(A,B,n) 1. d=0; i=0;indx=0; 2. for(i=0;iA[i]$ the larger value $v$ is propagated up similarly to MaxHeapInsert. If $v