Can we achieve linear time with groups of 7 in the SELECT algorithm?

  • Context: MHB 
  • Thread starter Thread starter evinda
  • Start date Start date
  • Tags Tags
    Linear Time
Click For Summary

Discussion Overview

The discussion revolves around the SELECT algorithm, specifically exploring whether it can achieve linear execution time when the input elements are divided into groups of 7 instead of the traditional groups of 5. Participants are also examining the implications of using groups of 3 and the associated time complexity of the algorithm's steps.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant outlines the steps of the SELECT algorithm and questions the potential for linear execution time with groups of 7.
  • Another participant suggests finding a recurrence relation to describe the algorithm's time complexity.
  • A participant asks for clarification on the proof regarding the time complexity when the input is divided into groups of 5.
  • Concerns are raised about the cost of the second step involving insertion sort, with a participant questioning how the cost is calculated given that insertion sort is applied to small groups of fixed size (5).
  • Another participant reiterates the question about the cost of the second step and seeks clarification on the cost for the fifth step.

Areas of Agreement / Disagreement

Participants do not appear to reach consensus on the time complexity implications of using different group sizes, and multiple viewpoints regarding the cost calculations and the potential for linear execution time remain unresolved.

Contextual Notes

Participants express uncertainty about the recurrence relations and the specific costs associated with the algorithm's steps, particularly in relation to the insertion sort and the implications of different group sizes.

Who May Find This Useful

This discussion may be of interest to those studying algorithm design, particularly in the context of selection algorithms and time complexity analysis.

evinda
Gold Member
MHB
Messages
3,741
Reaction score
0
Hello! (Wave)

The [m]SELECT[/m] algorithm determines the $i$th smallest element of an input array of $n>1$
distinct elements by executing the following steps.


  • 1. Divide the $n$ elements of the input array into $\lfloor \frac{n}{5} \rfloor $ groups of $5$ elements each and at most one group made up of the remaining $n \mod 5$ elements.
    2. Find the median of each of the $\lfloor \frac{n}{5} \rfloor $ groups by first insertion-sorting the elements
    of each group (of which there are at most $5$) and then picking the median
    from the sorted list of group elements.
    3. Use SELECT recursively to find the median $x$ of the $\lfloor \frac{n}{5} \rfloor $ medians found in step $2$. (If there are an even number of medians, then by our convention, $x$ is the lower median.)
    4. Partition the input array around the median-of-medians $x$ using the modified
    version of PARTITION. Let $k$ be one more than the number of elements on the
    low side of the partition, so that $x$ is the $k$th smallest element and there are $n-$k
    elements on the high side of the partition.
    5. If $i=k$, then return $x$. Otherwise, use SELECT recursively to find the $i$th
    smallest element on the low side if $i<k$, or the $i-k$ th smallest element on
    the high side if $i>k$.
At the algorithm [m]SELECT[/m], the input elements are divided into groups of $5$.

Can the algorithm achieve linear execution time if the elements get divided into groups of $7$?

Show that if groups of $3$ are used , linear execution time cannot be achieved.
How can we deduce if the algorithm can achieve linear execution time if the elements get divided into groups of $7$? (Thinking)
 
Last edited:
Technology news on Phys.org
We could find a recurrence relation that describes the algorithm, right? (Thinking)

Could you help me to find the time complexity of each of the steps?
 
Do you understand the proof when the length is divided by 5 ?
 
I saw that for the second step, the cost should be $c \cdot \lceil \frac{n}{5} \rceil$. How can this be the cost, although we apply Insertion sort? Also how can we find the cost for the step $5$? :confused:
 
evinda said:
I saw that for the second step, the cost should be $c \cdot \lceil \frac{n}{5} \rceil$. How can this be the cost, although we apply Insertion sort? Also how can we find the cost for the step $5$? :confused:

The insertion sort is done on lists with fixed length equal to 5 , right ?
 

Similar threads

Replies
9
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 36 ·
2
Replies
36
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 11 ·
Replies
11
Views
4K
Replies
25
Views
4K