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

  • Thread starter Thread starter evinda
  • Start date Start date
  • Tags Tags
    Linear Time
AI Thread Summary
The SELECT algorithm efficiently finds the $i$th smallest element in an array of distinct elements by dividing the array into groups, finding medians, and recursively partitioning. The process begins by grouping elements into sets of five, determining the median of each group through insertion sort, and then finding the median of these medians. The algorithm partitions the array around this median and recursively searches the appropriate side based on the desired index. A discussion point is whether using groups of seven could still yield linear execution time, prompting consideration of a recurrence relation to analyze time complexity. It is noted that using groups of three would not achieve linear time, leading to inquiries about the time complexity of each step, particularly regarding the cost of insertion sort on small groups and the overall cost in step five. The insertion sort is confirmed to be applied to fixed-length groups of five, raising questions about how this affects the algorithm's efficiency and complexity calculations.
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 ?
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top