Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider an algorithm sort(A) that takes as input an array A of integers. The algorithm works by calling aux(0, n, A) where n is the

Consider an algorithm sort(A) that takes as input an array A of integers. The algorithm works by calling aux(0, n, A) where n is the length of A and where aux(lo, hi, A) is a recursive algorithm. The arguments lo and hi of aux delimit the portion of the array A that aux sorts, namely A[lo], A[lo + 1], . . . , A[hi 1].

aux(lo, hi, A) works as follows:

1. If hi lo is 0 or 1, return. Otherwise go to the next step.

2. If hi lo is 2, put A[lo] and A[hi 1] in order (swap if needed) then return. Otherwise go to the next step.

3. Divide the array portion between lo and hi into three (approximately) equal parts. Call insertionsort to order the middle third, then recursively call aux for the lower third, and finally recursively call aux for the upper third.

4. Merge all three sorted parts.

a. Let T(n) be the worst-case running time for sort on an array of length n (assume that n is an exact power of 3). Write a recurrence relation for T(n). On the right side of the recurrence relation do not include the terms of the form c np where p 0, except for the term of highest degree. Explain your answer briefly.

b. Analyze the running time of the algorithm. Prove this.

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

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions

Question

Explain key aspects of e-learning

Answered: 1 week ago

Question

Question Who can establish a Keogh retirement plan?

Answered: 1 week ago