Question

In the algorithm SELECT, the input elements are divided into groups of 5. Show that the...

In the algorithm SELECT, the input elements are divided into groups of 5. Show that the algorithm works in linear time if they are divided into groups of 9

Homework Answers

Answer #1

Selection Algorithm is an algorithm for finding the kth smallest or largest number in a list or an array.

The algorithm will work in linear time if they are divided into groups of 9.

There are n/9 groups with at least 4.(1/2).(n/9) = (2n/9) elements that are less than or equal to the median of the medians and at least as many that are greater than or equal to the median of medians.

Thus, the larger subset after partitioning has at most n − 2n/9 = 7n/9 elements.

The running time is T(n) = T(n/9) + T(7n/9) + Θ(n)

Using substitution we assume: T(k) ≤ c ∗ k for k < n

= T(k) ≤ c ∗ (n/9) + c ∗ (7n/9) + c1n

= T(k) ≤ c ∗ (8n/9) + c1n

= T(k) ≤ c ∗ n + (c1 − c ∗ (1/9))n

= T(k) ≤ c ∗n which is linear if (c1 − c ∗ (1/9)) ≤ 0

Hence, the algorithm will work in linear time if they are divided into groups of 9.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
**please show all work and explain** An algorithm takes 0.5 seconds to run on an input...
**please show all work and explain** An algorithm takes 0.5 seconds to run on an input of size 100. How long will it take to run on an input of size 1000 if the algorithm has a running time that is linear? quadratic? log-linear? cubic?
design an efficient algorithm that, on input a set of n real numbers {x1, . ....
design an efficient algorithm that, on input a set of n real numbers {x1, . . . , xn}, outputs all distinct numbers in the set. For example, if your input is {5, 10, 9, 10, 8, 5, 12, 11, 12, 9, 7, 6, 8, 5}, then you should output {5, 10, 9, 8, 11, 12, 7, 6} (any ordering of these number is acceptable).
Find the worst-case complexity of the algorithm below. Show your work. UFSizeCalc Input:  uf: Union-Find array of...
Find the worst-case complexity of the algorithm below. Show your work. UFSizeCalc Input:  uf: Union-Find array of size n Input: n: size of uf Output: size array for uf; that is, an array s such that s[r] equals the number of elements in the Union-Find tree rooted at r, for every root r (s may have any value for indexes that are not roots of uf) Pseudocode: For i = 1 to n uf.Find(i) size = Array(n) Initialize size to be...
In class, we have studied the linear time algorithm for selection. In that algorithm, we have...
In class, we have studied the linear time algorithm for selection. In that algorithm, we have used groups of size 5. Suppose we are using groups of size 13. • derive the corresponding recurrence formula. • What is the corresponding time complexity of the algorithm? I found the reccurance relation to be T(n)=O(n)+T(n/13)+T(19n/26), but I am having trouble finding the time complexity. Also I really want to learn this, so a detailed response would be nice. I believe it is...
The selection algorithm generates two subproblems with size of n/5 and 7n/10, respectively. Is it possible...
The selection algorithm generates two subproblems with size of n/5 and 7n/10, respectively. Is it possible to make the two subproblems have equal size and still run in a linear time? If it is possible, how to partition the numbers into groups? If it is not possible, justify
An online/anytime sorting algorithm is one that reads its input numbers one at a time, and...
An online/anytime sorting algorithm is one that reads its input numbers one at a time, and maintains a sorted array of all the inputs it has seen so far, so that if it is interrupted at any time, it will still output the correct answer for the inputs that it has processed. Not all sorting algorithms are amenable to modification to make them anytime. But one sorting algorithm, Bubble Sort, is easy to so modify. First, understand the ascending order...
Design a recursive divide-and-conquer algorithm A(n) that takes an integer input n ≥ 0, and returns...
Design a recursive divide-and-conquer algorithm A(n) that takes an integer input n ≥ 0, and returns the total number of 1’s in n’s binary representation. Note that the input is n, not its binary representation. For example, A(9) should return 2 as 9’s binary representation is 1001, while A(7) should return 3 since 7 is 111 in binary. Note that your algorithm should have a running time of O(log n). Justify your answer. You need to do the following: (1)...
Imagine that we divided the class into groups of 5, everyone did one speed test on...
Imagine that we divided the class into groups of 5, everyone did one speed test on their own device, and we calculated variance and SD for each group. Then we calculated variance and SD for the entire class (n = about 45). How would variance and SD for the entire class differ from variance and SD for the smaller groups?
Compute the number of ways you can select n elements from N elements for each of...
Compute the number of ways you can select n elements from N elements for each of the following: N=9, n=4 N=9, n=5 N=8, n=4 N=8, n=5 Use the results of a, b, c, and d to verify the properties of combinations
1. 15 people are divided into 2 groups one with 5 and the other with 7...
1. 15 people are divided into 2 groups one with 5 and the other with 7 people in them. How many ways are there to do this? 2. 10 people including Mr.Joe and Mr.T are to be seated in a row. How many ways are there to do this so that they don't sit together? Please answer the problems using the easiest method possible. Thank You
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT