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

In summary, the SELECT algorithm finds the $i$th smallest element of an input array of $n>1$ distinct elements by dividing the elements into groups of 5, finding the median of each group, recursively finding the median of the medians, partitioning the array around the median-of-medians, and then recursively finding the $i$th smallest element on either the low or high side. The algorithm cannot achieve linear execution time if the elements are divided into groups of 7, and if groups of 3 are used, linear execution time cannot be achieved. To determine the time complexity of each step, we can find a recurrence relation and analyze the cost of each step. The cost of the second step is $c \
  • #1
evinda
Gold Member
MHB
3,836
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
  • #2
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?
 
  • #3
Do you understand the proof when the length is divided by 5 ?
 
  • #4
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:
 
  • #5
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 ?
 

1. Can we really achieve linear time or is it just a theoretical concept?

Achieving linear time is not just a theoretical concept, but it is a goal that scientists and researchers have been working towards for decades. Linear time refers to a system or process that can complete a task in a consistent amount of time, regardless of the input or complexity. While it may not be possible to achieve perfect linear time, significant progress has been made in improving the efficiency and speed of various systems and processes.

2. What are some examples of systems or processes that currently use linear time?

Some examples of systems or processes that currently use linear time include algorithms for sorting or searching data, mathematical calculations, and electrical circuits. These systems have been optimized and streamlined to significantly reduce the amount of time it takes to complete a task, making them more efficient and predictable.

3. Is it possible to achieve linear time in all systems and processes?

While linear time is a desirable goal, it may not be possible to achieve it in all systems and processes. Some tasks or processes inherently require more time and resources, and it may not be feasible to reduce the time it takes to complete them to a consistent amount. However, with advancements in technology and research, it is possible that we may discover new ways to achieve linear time in more systems and processes.

4. How can achieving linear time benefit society?

Achieving linear time can have numerous benefits for society. It can lead to faster and more efficient processes, which can save time and resources. This, in turn, can lead to increased productivity and economic growth. Linear time can also improve accuracy and reliability, making systems and processes more consistent and predictable.

5. What are some challenges in achieving linear time?

There are several challenges in achieving linear time, including technical limitations, resource constraints, and the inherent complexity of some tasks. It requires advanced knowledge and expertise in various fields such as mathematics, computer science, and engineering. Additionally, achieving linear time may also require significant investments in research and development, which can be a barrier for smaller organizations or countries.

Similar threads

Replies
9
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
17
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
13
Views
3K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
31
Views
2K
Back
Top