Modify the recursive quicksort to call mergesort

Assignment Help Data Structure & Algorithms
Reference no: EM131662311

Question: Suppose that the recursive quicksort receives an int parameter, depth, from the driver that is initially approximately 2 log N.

a. Modify the recursive quicksort to call mergeSort on its current subarray if the level of recursion has reached depth. (Hint: Decrement depth as you make recursive calls; when it is 0, switch to mergesort.)

b. Prove that the worst-case running time of this algorithm is O(N log N).

c. Conduct experiments to determine how often mergeSort gets called.

d. Implement this technique in conjunction with tail recursion removal in Exercise I.

e. Explain why the technique in Exercise II would no longer be needed.

Exercise II: Continuing from Exercise I, after part (a),

a. Perform a test so that the smaller subarray is processed by the first recursive call and the larger subarray is processed by the second recursive call.

b. Remove the tail recursion by writing a while loop and altering low or high, as necessary.

c. Prove that the number of recursive calls is logarithmic in the worst case.

Exercise I: The quicksort in the text uses two recursive calls. Remove one of the calls as follows.

a. Rewrite the code so that the second recursive call is unconditionally the last line in quicksort. Do so by reversing the if/else, and returning after the call to insertionSort.

b. Remove the tail recursion by writing a while loop and altering low.

Reference no: EM131662311

Questions Cloud

Dimensions of the new phone : The height of the new phone is 2.5 millimeters more than twice its width. Find the dimensions of the new phone.
Analyze the concept of resource scheduling : Prepare a paper in which you analyze the concept of resource scheduling and evaluating various methods used to schedule resources in project management.
What are the characteristics of high-quality information : What are the characteristics of high-quality information? What would happen if some of those characteristics are missing?
Unsavory reputation of the recent? past : Emerging from their often unsavory reputation of the recent? past, tattoos have gained increasing prominence as a form of body art and?self-expression.
Modify the recursive quicksort to call mergesort : Modify the recursive quicksort to call mergeSort on its current subarray if the level of recursion has reached depth.
Analysis of the nature and magnitude of their problem : Comment on the strengths and weaknesses of their analysis of the nature and magnitude of their problem and persons most affected.
Opening a new restaurant location : A fast food chain is thinking of opening a new restaurant location. The company conducts a market survey of students from the nearby college campus
What is the expected value : Does this make sense? what is the expected value after 10 rolls?
What is the equation of the line : Write the equation of the line in slope intercept form with slope m= -9/7 and passing through the point (-6,9)

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd