Chapter 3: Q22SE (page 233)
Find all pairs of functions of the same order in this list of functions: and
Short Answer
All pairs of functions does not have same order of using the fact that nhas a higher order than .
Chapter 3: Q22SE (page 233)
Find all pairs of functions of the same order in this list of functions: and
All pairs of functions does not have same order of using the fact that nhas a higher order than .
All the tools & learning materials you need for study success - in one app.
Get started for freeDevise 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.]
Express the relationship is using a picture. Show the graphs of the functions f (x) and Cg(x), as well as the constant k on the real axis.
a) Describe in detail (and in English) the steps of an algorithm that finds the maximum and minimum of a sequence of elements by examining pairs of successive elements, keeping track of a temporary maximum and a temporary minimum. Ifn is odd, both the temporary maximum and temporary minimum should initially equal the first term, and ifn is even, the temporary minimum and temporary maximum should be found by comparing the initial two elements. The temporary maximum and temporary minimum should be updated by comparing them with the maximum and minimum of the pair of elements being examined.
b) Express the algorithm described in part (a) in pseudocode.
c) How many comparisons of elements of the sequence are carried out by this algorithm? (Do not count comparisons used to determine whether the end of the sequence has been reached.) How does this compare to the number of comparisons used by the algorithm in Exercise 5?
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
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.