   Chapter 11.3, Problem 25ES ### 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

# How many comparisons between values of a [ j ] and x actually occur when insertion sort is applied to the array of exercise 21?

To determine

To find the no of total comparison between a[j] and x using algorithm segment.

Explanation

From the given

a =7a=3a=6a=9a=5

Initially given 5 elements and 5 is assigned to n. Initially set k to 2, x to a[k]= a=3 and j to k-1=2-1=1.Here, n=5,k=2,x=3,j=1.

First step to compare j0 the second element 3 which is less than first element 7 ,so need to assign the 7 as the second element and then j is decreased by 1.One comparison between x and a[j],followed by comparison j0 (stops the while loop as j=0) next assign the 3 as a first element

### 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 