In RandSelect, we use a pivot to partition (aka split) the data, in dn time, where d is a constant. Suppose that the partition is called “balanced” if each side of the pivot ends up with no more than 51% of the data. Otherwise the partition is unbalanced.Assume that we have truly random data.

(a) Provide a quick analysis to show that RandSelect will take O(n) expected time, by dealing with only two types of partitions (balanced vs unbalanced).

(b) What is the leading constant that you get, that is normally hidden in the big-O?

(c) What leading constant would you get if we had said that a balanced partition yields at most 99% of the data on one side?

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

Problem 1
We use the same approach as in the class notes.
The worst case if the split is balanced leads to T(n) ≤ T(51n/100) + dn
The worst case if the split is unbalanced leads to T(n) ≤T(n-1)+dn < T(n)+dn
Because each split has 50% chances to be balanced =>
T(n) ≤ 0.5*(T(51n/100) +dn) + 0.5*(T(n)+dn) =>
T(n) ≤ 0.5*T(n) + 0.5*T(51n/100) + dn =>
0.5*T(n) ≤ 0.5*T(51n/100) + dn =>
T(n) ≤ T(51n/100) + 2dn...

By purchasing this solution you'll be able to access the following files:

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Data Structures and Algorithms Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats