Chapter 3: Q41E (page 203)
Sort these lists using a selection sort
a)3,5,4,1,2 b)5,4,3,2,1 c)1,2,3,4,5.
a) 3,5,4,2,1
Short Answer
The sorted list using selection sort is1,2,3,4,5.
Chapter 3: Q41E (page 203)
Sort these lists using a selection sort
a)3,5,4,1,2 b)5,4,3,2,1 c)1,2,3,4,5.
a) 3,5,4,2,1
The sorted list using selection sort is1,2,3,4,5.
All the tools & learning materials you need for study success - in one app.
Get started for freea.) Describe the linear search and binary search algorithm for finding an integer in a list of integers in increasing order.
b.) Compare the worst-case time complexities of these two algorithms.
c.) Is one of these algorithms always faster than the other (measured in terms of comparisons)?
all terms of a finite sequence of integers that are greater than the sum of all previous terms of the sequence.
Describe an algorithm that inserts an integer xin the appropriate position into the list a1, a2, . . . , anof integers that are in increasing order.
Devise an algorithm to compute xn, where xis a real number and nis an integer. [Hint:First give a procedure for computing xnwhen nis nonnegative by successive multiplication by x, starting with 1. Then extend this procedure, and use the fact that xโn=1/xnto compute xnwhen nis negative.]
Compare the number of comparisons used by the insertion sort and the binary insertion sort to sort the list 7, 4, 3, 8, 1, 5, 4, 2.
What do you think about this solution?
We value your feedback to improve our textbook solutions.