Results 1 to 7 of 7
  1. #1
    louboulos is offline Member
    Join Date
    Mar 2011
    Posts
    25
    Rep Power
    0

    Default Quicksort median

    Hello. I have an excercise that asks the following:
    Consider a modification to QuickSort, such that each time "Partition" is called, the median of the portioned array is found and used as a pivot. Write a pseudocode fo that.

    I'm not asking for the answer. I just want to know what the median is. Is it the number that splits the array in half?
    i.e: In case of (1,2,3,4,5,6,7,8,9) the median is 5?
    Thank you.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,361
    Blog Entries
    7
    Rep Power
    20

    Default Re: Quicksort median

    Read this link.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    louboulos is offline Member
    Join Date
    Mar 2011
    Posts
    25
    Rep Power
    0

    Default Re: Quicksort median

    can someone else explain please what does the exercise want?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,361
    Blog Entries
    7
    Rep Power
    20

    Default Re: Quicksort median

    Quote Originally Posted by louboulos View Post
    can someone else explain please what does the exercise want?
    Have you read the link I gave you?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    louboulos is offline Member
    Join Date
    Mar 2011
    Posts
    25
    Rep Power
    0

    Default Re: Quicksort median

    yeah but I dont get much... :)

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,361
    Blog Entries
    7
    Rep Power
    20

    Default Re: Quicksort median

    Quote Originally Posted by louboulos View Post
    yeah but I dont get much... :)
    Don't just skim over it but study the material; there's even very clear pseudo code in there. We are not going to spoonfeed you ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Quicksort median

    I just want to know what the median is. Is it the number that splits the array in half?
    Yes, more or less. For the precise definition read the "median" link in the second sentence of the Wikipedia article you have already been pointed at.

Similar Threads

  1. Finding the Median
    By system5634 in forum New To Java
    Replies: 1
    Last Post: 02-07-2012, 01:30 PM
  2. Calculating Median and mode
    By rochla16 in forum New To Java
    Replies: 4
    Last Post: 04-29-2011, 04:24 AM
  3. Finding Median of X Integers
    By Hasan in forum New To Java
    Replies: 3
    Last Post: 08-12-2008, 02:06 PM
  4. Quicksort
    By little_polarbear in forum New To Java
    Replies: 12
    Last Post: 07-12-2008, 09:20 PM
  5. Quick sort with median-of-three partitioning
    By Java Tip in forum Algorithms
    Replies: 0
    Last Post: 04-15-2008, 07:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •