Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Standard 1 6 : Analyzing Code III: Writing Recurrences Problem 1 6 . Write down a recurrence for the number of times this algorithm prints

Standard 16: Analyzing Code III: Writing Recurrences
Problem 16. Write down a recurrence for the number of times this algorithm prints Hi. Clearly justify
your answer. You are not being asked to solve the recurrence.
Algorithm 1 Recurrences
1: procedure Merge3Sort(List L)
2: if len(L)=1 then return L
3: n len(L)
4: f irst Merge3Sort(L[0 : n/3])
5: second Merge3Sort(L[n/3 : 2n/3])
6: third Merge3Sort(L[2n/3 : n])
7: for i 1; i = n; i i +1 do
8: print Hi// This loop doesnt actually do anything! But has the same runtime as a 3-way merge
9: return L
Answer16 Standard 16: Analyzing Code III: Writing Recurrences
Problem 16. Write down a recurrence for the number of times this algorithm prints "Hi". Clearly justify
your answer. You are not being asked to solve the recurrence.
Algorithm 1 Recurrences
procedure MERGE3SoRT(List L)
if len(L)1 then return L
nlarrlen(L)
second larrMerge3Sort(L[n3:2n3])
third larrMerge3Sort(L[2n3:n])
for ilarr1;in;ilarri+1 do
print "Hi"// This loop doesn't actually do anything! But has the same runtime as a 3-way merge
return L
image text in transcribed

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

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions