CSE310-HW06

pdf

School

Arizona State University *

*We aren’t endorsed by this school

Course

310

Subject

Computer Science

Date

Apr 3, 2024

Type

pdf

Pages

2

Uploaded by AmbassadorWildcatMaster399

Report
CSE310 HW06, Wednesday, 04/19/2023, Due: Wednesday, 04/26/2023 Please read the instructions carefully. You have to use the companion answer sheet (which is a fillable PDF file) to type/select your answers to the questions described here . Hand-written assignment (or photo of it) will not be graded. Submit the filled PDF file of the answer sheet on Gradescope, following the link on Canvas . You should name your file using the format CSE310-HW06-LastName-FirstName.pdf . Make sure that your submission can be viewed clearly on gradescope for auto-grading. Q1 (12 points: 4 + 4 + 4) We have studied the linear time selection algorithm applied on n elements. Assume that all n elements are different. In the algorithm we have studied, we used group size of 5. We proved that the number of elements that are guaranteed to be larger than the median of medians is lower bounded by G ( n, 5) = 3 10 n 6. Similarly, the number of elements that are guaranteed to be smaller than the median of medians is also lower bounded by G ( n, 5). Therefore, the number of elements on either side of the median of medians after the partition is upper bounded by U ( n, 5) = n G ( n, 5) = 7 10 n +6. We concluded that the time complexity T 5 ( n ) of the algorithm satisfy the relation T 5 ( n ) T 5 ( n 5 ) + T 5 ( 7 n 10 + 6) + Θ( n ). This lead to T 5 ( n ) = Θ( n ). Answer the following questions. (a) Suppose we use group size of 11. What is G ( n, 11) (the number of elements that are guaranteed to be larger than the median of medians)? What is U ( n, 11)? What is the corresponding recurrence relation for the time complexity of the algorithm (denoted by T 11 ( n )? Is T 11 ( n ) = Θ( n )? (b) Suppose we use group size of 13. What is G ( n, 13) (the number of elements that are guaranteed to be larger than the median of medians)? What is U ( n, 13)? What is the corresponding recurrence relation for the time complexity of the algorithm (denoted by T 13 ( n )? Is T 13 ( n ) = Θ( n )? (c) Suppose we use group size of 3. What is G ( n, 3) (the number of elements that are guaranteed to be larger than the median of medians)? What is U ( n, 3)? What is the corresponding recurrence relation for the time complexity of the algorithm (denoted by T 3 ( n )? Is T 3 ( n ) = Θ( n )? Q2 (20 points) Given two sequences X=<C,A,D,B,A> and Y=<C,A,B,A> , you need to use dynamic programming to compute a longest common subsequence of X and Y . On the answer sheet, answer questions regarding the values of c[i, j] . Q3 (12 points) Suppose that we are using hashing with open addressing, where the (linear) probing sequence is defined by h ( k ) = k mod 13 1
and h ( k, i ) = ( h ( k ) + i ) mod 13 . The following questions all refer to the hash table in the following. j 0 1 2 3 4 5 6 7 8 9 10 11 12 T [ j ] 10 DELETED 9 DELETED DELETED 8 7 6 5 4 3 2 1 (a) What are the cells (the j values) probed when performing Hash-Insert(T, 24) to the hash table at the top of this page. (b) What are the cells (the j values) probed when performing Hash-Delete(T, 10) to the hash table at the top of this page. Q4 (6 points) Suppose that you need to choose a data structure to support the operations insertion , deletion , and searching . You need to choose between (1) red-black tree and (2) hashing with chaining (insertion at the head), where the table size m is much smaller than the number of elements n . On the answer sheet, write down the worst-case time complexities (using the most accurate asymptotic notation) for each of the operations on a corresponding data structure (assuming the number of elements is n and the hash table size is m ). (a) Insertion in hash table (b) Insertion in red-black tree (c) Deletion in hash table (d) Deletion in red-black tree (e) Searching in hash table (f) Searching in red-black tree 2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help