Chapter 3: Q39E (page 203)
Use the insertion sort to sort the list in Exercise 35, showing the list obtained at each step.
Short Answer
The sorted list using insertion sort is 1,3,4,5,7.
Chapter 3: Q39E (page 203)
Use the insertion sort to sort the list in Exercise 35, showing the list obtained at each step.
The sorted list using insertion sort is 1,3,4,5,7.
All the tools & learning materials you need for study success - in one app.
Get started for freeUse the greedy algorithm to make change using quarters, dimes, nickels, and pennies for
a) 51 cents. b) 69 cents.
c) 76 cents. d) 60 cents.
Change Algorithm 3 so that the binary search procedure compares x toat each stage of the algorithm, with the algorithm terminating if . What advantage does this version of the algorithm have?
Describe an algorithm that interchanges the values of the variables xand y, using only assignments. What is the minimum number of assignment statements needed to do this?
a.) Describe the insertion sort algorithm.
b.) Use the insertion sort algorithm to sort the list 2, 5, 1, 4, 3.
c.) Give a big-O estimate for the number of comparisons used by the insertion sort.
Describe an algorithm that takes as input a list of integers in non decreasing order and produces the list of all values that occur more than once. (Recall that a list of integers is non decreasing if each integer in the list is at least as large as the previous integer in the list.)
What do you think about this solution?
We value your feedback to improve our textbook solutions.