Question: they are all connected to this question pls help (its basically 1 question) Q1 Loop Invariants and Iterative Algorithm: MT 1 review 20 Points Answer

they are all connected to this question pls help (its basically 1 question)

they are all connected to this question pls help (its basically 1question) Q1 Loop Invariants and Iterative Algorithm: MT 1 review 20 PointsAnswer one of the first two review problems, and all of theother problems. Consider the following algorithm that takes two sorted lists ofintegers (A[1],,A[n]) and (B[1],..B[m]), and tests whether there are elements A[i] and

Q1 Loop Invariants and Iterative Algorithm: MT 1 review 20 Points Answer one of the first two review problems, and all of the other problems. Consider the following algorithm that takes two sorted lists of integers (A[1],,A[n]) and (B[1],..B[m]), and tests whether there are elements A[i] and B[j] so that A[i]B[j]2. For example if the input is: A[1..6]=(40,72,75,101,123,184) and B[1..6]=(13,17,33,38,94,142), the algorithm returns True because 40382. procedure CloseMatch (A[1],,A[n];B[1],,B[m]) : 1. J=1;I=1; 2. While Jm and In do: 3. IF A[I]B[J]2 Return True. 4. IFA[I]B[Jt]+2, show that JtB[Jt]+2, what are the values of It+1 and Jt+1 ? Q1.6 2 Points Induction step: Show that the invariant holds for the case A[It]>B[Jt]+2. You can use what you proved in iv. and v. Q1.7 4 Points Use the invariant to prove that the algorithm is correct. (You do not need to re-prove the invariant here, just use it.) Q1.8 4 Points Give a time analysis for this algorithm up to order in terms of n and m. Explain your answer referring to the algorithm. (2 points correct time, 2 points explanation)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!