Chapter 3: Q1SE (page 233)
a) Describe an algorithm for locating the last occurrence of the largest number in a list of integers.
b) Estimate the number of comparisons used.
Short Answer
(a) procedure last largest
for ton
if then
return position
Chapter 3: Q1SE (page 233)
a) Describe an algorithm for locating the last occurrence of the largest number in a list of integers.
b) Estimate the number of comparisons used.
(a) procedure last largest
for ton
if then
return position
All the tools & learning materials you need for study success - in one app.
Get started for freeDescribe an algorithm that determines whether a function from a finite set of integers to another finite set of integers is onto.
a)Devise a variation of the insertion sort that uses a linear search technique that inserts the j th element in the correct place by first comparing it with the (j−1)st element, then the (j−2)th element if necessary, and so on.
b) Use your algorithm to sort 3, 2, 4, 5, 1, 6.
c) Answer Exercise 45 using this algorithm.
d) Answer Exercise 46 using this algorithm.
Write the selection sort algorithm in pseudo code
Describe an algorithm to find the longest word in an English sentence (where a sentence is a sequence of symbols, either a letter or a blank, which can then be broken into alternating words and blanks).
Use 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.
What do you think about this solution?
We value your feedback to improve our textbook solutions.