Chapter 3: Q25E (page 231)
Describe the worst-case time complexity, measured in terms of comparisons, of the ternary search algorithm described in Exercise 27 of Section 3.1.
Short Answer
O(log n)
Chapter 3: Q25E (page 231)
Describe the worst-case time complexity, measured in terms of comparisons, of the ternary search algorithm described in Exercise 27 of Section 3.1.
O(log n)
All the tools & learning materials you need for study success - in one app.
Get started for freea) Describe an algorithm for finding the first and second largest elements in a list of integers.
b) Estimate the number of comparisons used.
Devise an algorithm that finds the first term of a sequence of positive integers that is less than the immediately preceding term of the sequence.
Suppose that f(x) is O (g(x)) where f and g are increasing and unbounded functions. Show that log│f(x)│ is O (log│g(x)│).
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.
Describe an algorithm that takes as input a list of n distinct integers and finds the location of the largest even integer in the list or returns 0 if there are no even integers in the list.
What do you think about this solution?
We value your feedback to improve our textbook solutions.