Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago