Develop a new partitioning function

Assignment Help Computer Engineering
Reference no: EM132117902

Quick sort is to partition the array around one element and then sort each part recursively. We pick up one element as the pivot and then move all elements less than the pivot to the left, and all elements greater than the pivot to the right.

We then recurse on the left and right parts. In a case of an array that contains many duplicates, quicksort will recurse on all duplicates of the pivot element.

You are to develop a new partitioning function that works better on arrays with duplicates. The idea is to partition the array into elements less than the pivot, equal to the pivot and greater than the pivot. 2

(a) Write a pseudocode for your suggested partitioning algorithm. Make sure your algorithm is in-place (i.e., do not use more than a constant amount of extra space).

(b) Using your suggested partitioning algorithm in part (a), come up with a sorting algorithm. Analyze the worst-case running time of your algorithm.

(c) Find an array on which the original quicksort runs in time ?(n 2 ) but your algorithm from (b) runs in ?(n).

Reference no: EM132117902

Questions Cloud

Compute your bank balance for the given time periods : Interest on your bank balance: Suppose your bank account has a balance today of $100. Consider the following time periods: t = 0, t = 1, t = 2, t = 12, t = 24.
What is the required return on portfolio : The risk-free rate is 6.4 percent and the market risk premium is 5 percent. Assume that required returns are based on the CAPM. Your $1 million portfolio
List relevant quantitative data : List relevant qualitative data: Evidence related to or based on the quality or character of something - List relevant quantitative data
How sensitive is the calculation to the rate of return : Stock returns and your retirement account: Suppose your retirement account has a balance today of $25,000 and you are 20 years old.
Develop a new partitioning function : Using your suggested partitioning algorithm in part (a), come up with a sorting algorithm. Analyze the worst-case running time of your algorithm.
Assuming an nominal interest rate : What was the effective price you received for the motorcycle assuming an nominal interest rate of 8.5%? Show your answer to the nearest $.01.
Label the value of per capita gdp on the graph : The ratio scale: Plot the following scenarios for per capita GDP on a ratio scale. Assume that per capita GDP in the year 2015 is equal to $10,000.
Which argument do you find more convincing : The costs of economic growth? In addition to the benefits of economic growth, there are also potentially costs. What are some of these costs?
What is the price of a 15-year : What is the price of a 15-year, zero coupon bond paying $1,000 at maturity, assuming semiannual compounding, if the YTM is: a. 6 percent? b. 8 percent? c. 10 pe

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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