By what amount have we increased the likelihood

Assignment Help Data Structure & Algorithms
Reference no: EM131036666

Median-of-3 partition

One way to improve the RANDOMIZED-QUICKSORT procedure is to partition around a pivot that is chosen more carefully than by picking a random element from the sub array. One common approach is the median-of-3 method: choose the pivot as the median (middle element) of a set of 3 elements randomly selected from the sub array. For this problem, let us assume that the elements in the input array A[1 ? n] are distinct and that n ≥ 3. We denote the sorted output array by A"[1 ? n]. Using the median-of-3 method to choose the pivot element x, define pi = Pr{x = A"[i]}.

a. Give an exact formula for pi as a function of n and i for i = 2, 3,..., n - 1. (Note that p1 = pn = 0.)

b. By what amount have we increased the likelihood of choosing the pivot as x = A"[⌊(n + 1/2⌋], the median of A[1 ? n], compared to the ordinary implementation? Assume that n → ∞, and give the limiting ratio of these probabilities.

c. If we define a "good" split to mean choosing the pivot as x = A"[i], where n/ ≤ i ≤ 2n/3, by what amount have we increased the likelihood of getting a good split compared to the ordinary implementation? (Hint: Approximate the sum by an integral.)

d. Argue that in the Ω(n lg n) running time of quicksort, the median-of-3 method affectsonly the constant factor.

Reference no: EM131036666

Questions Cloud

Construct an appropriate diagonalizing matrix : Construct an appropriate diagonalizing matrix, decouple the linear system - Construct an appropriate diagonalizing matrix, decouple the linear system, then solve the nonhomogeneous system.
Classical model and the solo growth model : What are the differences between the Classical Model and the Solo Growth Model in macroeconomics?
Implementing an expansionary monetary policy : 1. In 1992 the Central Bank of Japan resisted implementing an expansionary monetary policy because
Determine the gravimetric analysis of the mixture : A gas mixture has the following composition on a mole basis: 60 percent N2 and 40 percent CO2
By what amount have we increased the likelihood : If we define a "good" split to mean choosing the pivot as x = A"[i], where n/ ≤ i ≤ 2n/3, by what amount have we increased the likelihood of getting a good split compared to the ordinary implementation?
Find community program -focuses on addressing health issues : Identify one community based program (in Prince George's County, Maryland or Washington, D.C) that focuses on addressing health issues. The program will focus on behavior change, changing local environments for health, or developing new health pol..
Determine the mass fractions of the constituents of air : The composition of moist air is given on a molar basis to be 78 percent N2, 20 percent O2, and 2 percent water vapor.
Transactions demand for money : According to Baumol and Tobin, the transactions demand for money is
Business matters within the company : Mr. Smith is a retired director of XYZ Co Ltd, he was not appointed a director for the current year (2014), but still attends to many of the business matters within the company, and also attends the directors meetings to advise and mentor the new ..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  The traveling salesman problem is a somewhat misleading

The traveling salesman problem (TSP) is a somewhat misleading title as it does not always relate to a salesman.

  Is there a feasible solution for the problem

he running time of A on an input of size n is e(n log n). Given an input x of size n, give an algorithm that runs in time 0(n log2 n) and finds the cost of an optimal solution for x.

  Contents of registers for independent memory-reference

Find out the contents of registers PC, AR, DR, AC, and IR for two independent memory-reference instructions below. Each instruction starts with given Initial values.

  Question related to normalization

Think about a typical job order that might include the following information. Design a single table to hold all the data needed to store a job order including this information.

  Write a program to simulate the behavior of an array

Write a program to simulate the behavior of an m * n array of two-input NAND gates. This circuit, contained on a chip, has j input pins and k output pins.

  Design a 3-way merge sort algorithm

Design a 3-way merge sort algorithm, which divides the given array into three equal parts, recursively sorts each part, then merges the results.

  Data array a has data series from 1000000 to 1 with step

data array a has data series from 1000000 to 1 with step size 1 which is in perfect decreasing order.data array b has

  Determine the sequence of pairwise matrix multiplication

Determine the sequence of pairwise matrix multiplication to use. Show the steps of the algorithm - Bellman-Ford algorithm on this graph. Show the steps of the algorithm.

  Graph algorithm.

Graph algorithm. a. Draw a depth-first search tree based on a given graph. Assume that adjacent vertices are visited in alphabetical order. Then compute the Num and Low values for each vertex, and find out the articulation points i

  Create a solution algorithm that employs loops.

Given a simple problem that requires iteration, create a solution algorithm that employs loops. Given a simple problem that requires simple data structures, design, code, and test a solution algorithm that uses arrays

  Write the implementation of a data structure

Write an implementation of a data structure S that supports the following operations: Insert(S, x): insert the key x into S only if it is not already there.

  Question about unix commands

Assume you have a document called records.txt having the list of employee id and workers names. Every line contains a single employee id immediately followed by the employee name in the format Last name, First name.

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