Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9230567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:51:27+00:00 2026-06-18T05:51:27+00:00

From the Cormen Leiserson Rivest Stein, 3th Edition, Problem 9-1, point C, pag. 224

  • 0

From the “Cormen Leiserson Rivest Stein, 3th Edition, Problem 9-1, point C, pag. 224”, I have the following assignment:

Given a set (array) A of n numbers, use an order-statistic
algorithm to find the i-th largest number, partition around that
number, and sort the i largest numbers.

I used the Randomized-Select algorithm (from the same book, pag. 216 – it uses the Randomized-Partition algorithm) that finds the i-th smallest number, while I want to find the i-th largest number (let’s call it “k-th” to avoid confusion). Basically, I can obtain the k-th largest number as:

n – ith + 1

Then I call RandomizedSelect() to find the k-th largest number and all works great!

Here there is an example (in C) of how I find the 4-th largest number:

int A[10] = {3, 20, 15, 4, 1, 9, 18, 64, 22, 5}; // the given A set
int ith = 4; // I want to find the 4-th largest number of A
int kth = 10 - ith + 1; // I do this "conversion" for the reasons I explained above
int i = RandomizedSelect(A, 0, 9, kth); // it returns the index of A pointing to the 4-th largest number

printf("A vector: ");
for (j = 0; j < 10; j++) printf ("%u ", A[j]); // prints the A vector partially "ordered"

printf("\n4-th largest number: %u", A[i]); // prints the 4-th largest number

And here there is an example of the output:

A vector: 3 1 4 5 9 15 18 64 22 20

4-th largest number: 18

Now I want not only the 4-th largest number, but also the others 4 largest numberS in an ordered way (from the example: 18 20 22 64). So I just run for example MergeSort() on the A vector, starting from the i-th index found before until the end. The output will be: 18 20 22 64.

The problem is that the assignment says that I have to partition around the i-th (4-th) largest number and order the other i (4) largest numbers, and then run MergeSort() as explained before. But I can’t understand why should I do that… In my example, partitioning around 18 means nothing, because I tried and this has been the output of the A vector after I did that partition (calling SelectedPartition()):

3 1 4 5 9 15 18 64 22 20

18

…it’s the same output!

So, what did I misunderstand of the assignment? Or, am I doing it in a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:51:29+00:00Added an answer on June 18, 2026 at 5:51 am

    There are many different algorithms for computing order statistics. Many, like quickselect or the median-of-medians algorithm, automatically partition the array around the kth element as part of their implementation. However, there is no guarantee that the selection algorithm has to do this. For example, you could implement selection by putting all the elements into an order statistic tree data structure, then querying the kth element. As a result, it is most correct to put in the explicit partition step to ensure the partition happens.

    In your case, since you’re using an algorithm that already does a partition, you can safely ignore this step.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am studying the Ford-Fulkerson algorithm from Cormen's Introduction to algorithms 2nd Edition. It
From my website, I have a button which calls a method and then generates
From the Scala API , I got the following example, which does not compile;
I am trying to program the quicksort algorithm from Cormen Algorithm Textbook. Below is
I am refreshing on algorithm theory (from Cormen). There is an exercise in the
Taken from Introduction to Algorithms by Thomas Cormen: To keep things simple, we assume,
I am reading about Dynamic programming in Cormen etc book on algorithms. following is
I am working through the Introduction to Algorithms book by Cormen, and I have
From an efficiency and best practices point of view, I appreciate everyones thoughts. I
from title it appears a stupid question :) i know but i have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.