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
SUMMARY

The SELECT algorithm efficiently finds the $i$th smallest element in an array of distinct elements by dividing the array into groups of 5 and recursively determining medians. The discussion explores whether using groups of 7 can still achieve linear time complexity, contrasting it with the known inefficacy of groups of 3. Key steps include median finding, partitioning, and recursive selection, with a focus on establishing a recurrence relation for time complexity analysis.

PREREQUISITES
  • Understanding of the SELECT algorithm and its steps
  • Familiarity with median finding techniques
  • Knowledge of time complexity analysis and recurrence relations
  • Basic principles of insertion sort
NEXT STEPS
  • Research the time complexity of the SELECT algorithm with groups of 7
  • Study the impact of group size on the efficiency of selection algorithms
  • Learn about recurrence relations in algorithm analysis
  • Examine the performance of insertion sort on fixed-length lists
USEFUL FOR

Algorithm designers, computer scientists, and students studying data structures and algorithms, particularly those interested in selection algorithms and their complexities.

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