Question

Suppose we use RANDOMIZED-SELECT to select the minimum element of the array A = {12, 0,...

Suppose we use RANDOMIZED-SELECT to select the minimum element of the array A = {12, 0, 4, 3, 5, 7, 9, 2, 8, 11}. Describe a sequence of partitions that results in a worst-case performance of RANDOMIZEDSELECT.

Homework Answers

Answer #1

Q.Suppose we use RANDOMIZED-SELECT to select the minimum element of the array A = {12, 0, 4, 3, 5, 7, 9, 2, 8, 11}. Describe a sequence of partitions that results in a worst-case performance of RANDOMIZEDSELECT.

Answer:

In the example, the sequence would be{ 12,11,9,8,7,5,4,3,2,0 }

  • pivot 12 { 0,4,3,5,7,9,2,8,11}
  • pivot 11 {0,4,3,5,7,9,2,8}
  • pivot 9 {0,4,3,5,7,2,8}
  • pivot 8 {0, 4, 3, 5,7,2 }
  • pivot 7 {0, 4, 3, 5, 2}
  • pivot 5 {0, 4, 3, 2}
  • pivot 4 {0, 3, 2}
  • pivot 3 {0, 2}
  • pivot 2 {0}
  • return 0
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
We are given an array A of size n containing n positive and negative integers (the...
We are given an array A of size n containing n positive and negative integers (the array is indexed starting from 0). Our goal is to find two indices i and j such that 0 ≤ i ≤ j ≤ n and Pk=j k=i A[k] is maximized. Input sequence: [2, -4, 1, 9, -6, 7, -3] Output: [1, 9, -6, 7] or i = 2 and j = 5 Input sequence: [1, 2, 3, 4, 5, 6, -3] Output: [1,...
Use the following to answer the questions below: Below are the marginal costs of abating pollution...
Use the following to answer the questions below: Below are the marginal costs of abating pollution for three firms in an industry, based on their emissions levels. Each firm is now emitting 10 tons/week, so total emissions are 30 tons/week. Suppose we wish to reduce total emissions by 50 percent, to 15 tons per week in this industry. Marginal Abatement Costs ($/ton) Emissions (tons/week) Firm 1 Firm 2 Firm 3 10 0 0 0 9 5 1 1 8 9...
Suppose we consider a bus "old" if it has been in service more than 8 years....
Suppose we consider a bus "old" if it has been in service more than 8 years. At the 0.01 significance level, can we conclude that less than 40% of the district's buses are old? Report the p-value. Age 5 2 10 2 2 5 10 8 7 9 10 10 4 6 6 6 3 3 8 8 3 9 7 3 9 8 4 6 9 6 9 9 1 6 8 9 9 11 9 7 6 9...
The code segment in Listing 1, when completed and executed, creates nums, an uninitialized 4-integer array....
The code segment in Listing 1, when completed and executed, creates nums, an uninitialized 4-integer array. It stores 4 and 5 as the first and second elements, respectively, of the array. It adds the first and second elements of the array and stores their sum as the third element of the nums. It prints the third element of nums. It then adds the second and third elements of the array and stores their sum as the fourth element of nums....
For questions 1 and 2 declare the array size as name constant first then use it...
For questions 1 and 2 declare the array size as name constant first then use it to declare the array 1. Declare an array named scores of type double and size 30. 2. Declare an array named names of string objects and size 15 3. Given the following array definition: int values[] = {2, 5, 8, 11}; What does each of the following display? cout << values[1];         B) cout << value[3]+values[0];   Define a three element array named letters, initialize it...
Given the following unordered array: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]...
Given the following unordered array: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] W X D T P N R Q K M E If the array was being sorted using the SHELL sort and the halving method, and sorting into ASCENDING order as demonstrated in the course content, list the letters in the resulting array, in order AFTER the FIRST pass. [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
2.  Suppose we have 3 arrays A, B, and C, array A’s base address is in $S3,...
2.  Suppose we have 3 arrays A, B, and C, array A’s base address is in $S3, B’s base address is in $S4, C’s base address is in $S5. You can only use two temporal registers $t0 and $t1. Convert the following code into MIPS assembly language code. Suppose every array element occupies 1 word in MIPS (32 bits). A[21] = B[0] + C[16];
Consider the experimental results for the following randomized block design. Make the calculations necessary to set...
Consider the experimental results for the following randomized block design. Make the calculations necessary to set up the analysis of variance table. Treatment A B C 1 11 10 9 Blocks 2 12 6 6 3 18 16 14 4 21 18 19 5 8 8 9 Use = .05 to test for any significant differences. Show entries to 2 decimals, if necessary. Round p-value to four decimal places. If your answer is zero enter "0". Source of Variation Sum...
Consider the following array: int[] a = { 3, 5, 2, 2, 4, 7, 0, 8,...
Consider the following array: int[] a = { 3, 5, 2, 2, 4, 7, 0, 8, 9, 4 }; What are the contents of the array a after the following loops complete? (show how you arrive at the answer) a) for (int i = 1; i < 10; i++) { a[i] = a[i - 1]; b) for (int i = 9; i > 0; i--) { a[i] = a[i - 1]; }
(Data Structure) Suppose we want to store the data of a binary heap in an array....
(Data Structure) Suppose we want to store the data of a binary heap in an array. Show the data of that array after inserting the given keys one by one. Assume that initially binary heap is empty. Show all steps of insertions. Note: No need to show the changes for each step of “percolate up”. The contents of the array must be shown after completing one insertion. Create the “Min Heap” for the following data set 7,      3,      18,    -9,    ...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT