Question

Give a worst-case input sequence of 6 numbers for Insertion Sort, containing the numbers 21, 16,...

Give a worst-case input sequence of 6 numbers for Insertion Sort, containing the numbers

21, 16, 77, 3, 8, and 11.No explanation/proof required.

Homework Answers

Answer #1

The simplest worst case input is an array sorted in reverse order. The set of all worst case inputs consists of all arrays where each element is the smallest or second-smallest of the elements before it. In these cases every iteration of the inner loop will scan and shift the entire sorted subsection of the array before inserting the next element. This gives insertion sort a quadratic running time (i.e., O(n2)).

So the worst case input sequence would be :

(77, 21, 16, 11, 8, 3)

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
in C++ Please and thanks Here is a list of 6 numbers. Use the selection sort...
in C++ Please and thanks Here is a list of 6 numbers. Use the selection sort algorithm to sort this list. Fill in this table with each iteration of the loop in the selection sort algorithm. Mark the place from which you are looking for the 'next smallest element'. In this display, the upper numbers are the indices, the lower numbers are in the corresponding positions. Use the several rows provided to show the sequence of steps. 0 1 2...
CAN YOU PLEASE ANSWER ALL THESE QUSTIONS 1.In Merge sort, how many additional recursive partitioning levels...
CAN YOU PLEASE ANSWER ALL THESE QUSTIONS 1.In Merge sort, how many additional recursive partitioning levels are required for a list of 64 elements compared to a list of 8 elements? a. 3 b. 9 c. 8 d. 6 2. Which function best represents the number of operations in the worst-case for the following code fragment? for (i = 0; i < N; ++i) {    if (numbers[i] % 2 == 1)       factor = 2.5 } a. f(N) = 6N2 b....
Pinky and The Brain are great friends. They like to play games with numbers. This time,...
Pinky and The Brain are great friends. They like to play games with numbers. This time, Pinky has given The Brain a list of numbers and given him the task of determining if it is possible to choose a subset of them such that they sum is equal to another given number. Build an algorithm using dynamic programming to help The Brain with his problem. INPUT The first line corresponds to N, the amount of numbers given by Pinky The...
These numbers have been drawn from a uniform distribution with range 1-40. 4, 6, 16, 12,...
These numbers have been drawn from a uniform distribution with range 1-40. 4, 6, 16, 12, 23, 19, 16 26, 14, 12, 12, 10, 3, 26, 35, 8, 30, 11, 14, 34, 37, 16, 36, 30, 18, 39, 24, 18, 39, 5, 12, 28, 4, 12, 34, 16, 35, 27, 15, 1 Test the sample for randomness using: a Kolmogorov—Smirnov test.
These numbers have been drawn from a uniform distribution with range 1-40. 4, 6, 16, 12,...
These numbers have been drawn from a uniform distribution with range 1-40. 4, 6, 16, 12, 23, 19, 16 26, 14, 12, 12, 10, 3, 26, 35, 8, 30, 11, 14, 34, 37, 16, 36, 30, 18, 39, 24, 18, 39, 5, 12, 28, 4, 12, 34, 16, 35, 27, 15, 1 Test the sample for randomness using: a graphical method.
Month 1 2 3 4 5 6 7 Value 24 15 21 13 19 21 16...
Month 1 2 3 4 5 6 7 Value 24 15 21 13 19 21 16 a) Develop a three-month moving average for this time series. Compute MSE and a forecast for month 8. If required, round your answers to two decimal places. Do not round intermediate calculation. MSE:_______ The forecast for month 8________ b) Use α = 0.2 to compute the exponential smoothing values for the time series. Compute MSE and a forecast for month 8. If required, round...
6.Question 6 What is said to occur when the effect of one input factor on the...
6.Question 6 What is said to occur when the effect of one input factor on the output depends on the level of another input factor? 1 point Factors Blocking ANOVA Interaction 7.Question 7 When performing analysis of variance for a single factor experiment, which of the following is a required assumption? 1 point Means are equal Errors are equal Variances are equal Sample sizes are equal 8.Question 8 What test statistic is used for ANOVA? 1 point Chi-square F T...
Written in MASM Assembly Problem Definition: Write a program to calculate Fibonacci numbers. • Display the...
Written in MASM Assembly Problem Definition: Write a program to calculate Fibonacci numbers. • Display the program title and programmer’s name. Then get the user’s name, and greet the user. • Prompt the user to enter the number of Fibonacci terms to be displayed. Advise the user to enter an integer in the range [1 .. 46]. • Get and validate the user input (n). • Calculate and display all of the Fibonacci numbers up to and including the nth...
Kuya teaches a two-trimester course in Passionate Analysis Involving Numbers (PAIN). He would like to know...
Kuya teaches a two-trimester course in Passionate Analysis Involving Numbers (PAIN). He would like to know if these students improved their scores in their second trimester of the course. Is there a significant difference in PAIN scores? Apparently a couple students were too 'pained' and dropped out after the first trimester (too bad so sad). STUDENT TRIMESTER 1 TRIMESTER 2 1 69 78 2 76 79 3 70 81 4 71 5 75 57 6 61 55 7 67 59...
The data set entitled ‘Salmon’ contains 40 annual counts of the numbers of recruits and spawners...
The data set entitled ‘Salmon’ contains 40 annual counts of the numbers of recruits and spawners in a salmon population. The units are thousands of fish. Recruits are fish that enter the catchable population. Spawners are fish that are laying eggs. Spawners die after laying eggs. The classic Beaverton-Holt model for the relationship between spawners and recruits is R = 1 /(β1 + β2/S) where R and S are the numbers of recruits and spawners, respectively. This model may be...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT