c05 · E1

Practise: How Long Does It Take?

c05.E1.1E1 · numeric

A one-pass maximum scan compares each new item with the best so far and replaces the best when the new item wins. On a list of twelve items it performs 11 comparisons. In the worst case it also performs one replacement for every item after the first. Give the worst-case step count, counting one comparison or one replacement as a step.

c05.E1.2E1 · numeric

Two procedures sort a list. The first performs steps on items, and the second performs steps. At the first procedure is still ahead. Find the smallest whole at which the second procedure performs more steps than the first.

c05.E1.3E1 · numeric

A procedure performs steps on an input of size . At it performs 1,000 steps. Give its step count at .

c05.E1.4E1 · numeric

Merge sort on cards obeys with . Section 5.3 gives the closed form for powers of two. Compute .

c05.E1.5E1 · numeric

Suppose a sorting procedure splits items into items and 1 item, sorts each part, and spends comparisons merging. Its cost obeys with . Compute .

c05.E1.6E1 · numeric

Five cards carry five different numbers. A comparison sort asks only yes-or-no questions about pairs of cards. Give the smallest number of comparisons that any such procedure can be forced to use on five cards.

c05.E1.7E1 · numeric

The naive recursion for Fibonacci makes calls, where . Give .

c05.E1.8E1 · numeric

A brute-force search examines candidate settings of switches. At one billion checks per second, how long does the search take at ? Give the answer in days, to two decimal places.

Other tiers

E2 Derive · E3 Open

Every hint opened, solution viewed and answer checked is recorded in this browser only. See Progress to export or delete it.