Chapter 3: Q1E (page 202)
List all the steps used by algorithm 1 to find the maximum of the list
1, 8, 12, 9, 11, 2, 14, 5, 10, 4
Short Answer
The maximum of 1, 8, 12, 9, 11, 2, 14, 5, 10, 4 is 14.
Chapter 3: Q1E (page 202)
List all the steps used by algorithm 1 to find the maximum of the list
1, 8, 12, 9, 11, 2, 14, 5, 10, 4
The maximum of 1, 8, 12, 9, 11, 2, 14, 5, 10, 4 is 14.
All the tools & learning materials you need for study success - in one app.
Get started for freea) Adapt Algorithm 1 in Section 3.1 to find the maximum and the minimum of a sequence of elements by employing a temporary maximum and a temporary minimum that is updated as each successive element is examined.
b) Describe the algorithm from part (a) in pseudocode.
c) How many comparisons of elements in the sequence are carried out by this algorithm? (Do not count comparisons used to determine whether the end of the sequence has been reached.)
Determine which characteristics of an algorithm described in the text(after algorithm 1) the following procedures have and which they lack.
a)
b)role="math" localid="1668412435330"
c)
d)role="math" localid="1668412892026"
Show that a greedy algorithm that schedules talks in a lecture hall, as described in Example 7, by selecting at each step the talk that overlaps the fewest other talks, does not always produce an optimal schedule.
Describe an algorithm that uses only assignment statements that replaces the triple (x, y, z)with (y, z, x). What is the minimum number of assignment statements needed?
Adapt the bubble sort algorithm so that it stops when no interchanges are required. Express this more efficient version of the algorithm in pseudo code?
What do you think about this solution?
We value your feedback to improve our textbook solutions.