Consider the Algorithm given below in the image What is the Invariant of Algorithm? Analyze Algorithm by finding T(n) the running time of Algorithm on an input of n values. What is the best-case running time and the worst-case running time?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Consider the Algorithm given below in the image

  1. What is the Invariant of Algorithm?
  2. Analyze Algorithm by finding T(n) the running time of Algorithm on an input of n values.
  3. What is the best-case running time and the worst-case running time?

 

PLEASE REFER TO IMAGE BEFORE ANSWERING, ALL DATA IS PROVIDED IN IT!

Question No 1
Consider the Algorithm given below.
MERGE(A, p.q. r)
1 n1 = q – p +1
2 n2 = r - 9
3 let L[1..n + 1] and R[1..n2 + 1] be new arrays
4 for i = 1 to n
L[i] = A[p+i – 1]
1 to n2
R[j] = A[q + j]
8 L[n1 + 1] = 0
9 R[n2 + 1] = ∞
5
6 for j
7
10 i = 1
11 j = 1
12 for k = p to r
if L[i] < R[j]
A[k] = L[i]
i = i +1
else A[k] = R[j]
j = j +1
1. What is the Invariant of Algorithm?
13
14
15
16
17
2. Analyze Algorithm by finding T(n) the running time of Algorithm on an input of n values.
3. What is the best-case running time?
4. What is the worst-case running time?
Transcribed Image Text:Question No 1 Consider the Algorithm given below. MERGE(A, p.q. r) 1 n1 = q – p +1 2 n2 = r - 9 3 let L[1..n + 1] and R[1..n2 + 1] be new arrays 4 for i = 1 to n L[i] = A[p+i – 1] 1 to n2 R[j] = A[q + j] 8 L[n1 + 1] = 0 9 R[n2 + 1] = ∞ 5 6 for j 7 10 i = 1 11 j = 1 12 for k = p to r if L[i] < R[j] A[k] = L[i] i = i +1 else A[k] = R[j] j = j +1 1. What is the Invariant of Algorithm? 13 14 15 16 17 2. Analyze Algorithm by finding T(n) the running time of Algorithm on an input of n values. 3. What is the best-case running time? 4. What is the worst-case running time?
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY