   Chapter 11.3, Problem 3TY ### Discrete Mathematics With Applicat...

5th Edition
EPP + 1 other
ISBN: 9781337694193

#### Solutions

Chapter
Section ### Discrete Mathematics With Applicat...

5th Edition
EPP + 1 other
ISBN: 9781337694193
Textbook Problem
1 views

# The worst-case order of the insertion sort algorithm is , and its average-case order is _______.

To determine

To fill in the blanks of the given statement “The worst-case order of the insertion sort algorithm is _______ and its average case order is _____.”

Explanation

Given:

The incomplete statement “The worst-case order of the insertion sort algorithm is _______ and its average case order is _____.”

Formula used:

The order of a polynomial is given by,

If m is any integer with m0 and a1,a2,...,am are real numbers with am>0, then amnm+am1nm1+...+a1n+a0 is θ(nm)

The worst case of the insertion sort algorithm is that the number of iterations reach to its maximum. When the array is in the reverse order, we get the maximum number of iterations. Also, when the comparison goes to the last element, there is no more elements to compare with which means there is no comparison for the last element.

Hence, we can calculate the total number of comparisons for n size array as follows.

2+3+4+..+n=(1+2+3+4+..+n)1=n( n+1)21=n22+n21

Let, p(n)=n22+n21 and according to the theorem of the order of a polynomial p(n) is θ(n2)

Also, in the average case of the insertion sort algorithm, each element is about halfway in order of the array

### Still sussing out bartleby?

Check out a sample textbook solution.

See a sample solution

#### The Solution to Your Study Problems

Bartleby provides explanations to thousands of textbook problems written by our experts, many with advanced degrees!

Get Started 