Skip to content

Activity selection

planning ahead

Level 1 of 3

Also called Interval scheduling and Earliest finish time first.

fresh numbers

The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from activity selection's own run on the numbers shown.

choose one

question 1

These four activities are typed in this order: A from 0 to 4, B from 4 to 7, C from 0 to 5 and D from 5 to 8. The drawing lines them up by end. How many comparisons does the sort make?

012345678ACBDAAAACCCCCBBBDDD
the answer, and why

the answer is C

Round 1 sorts each pair, 1 comparison each: A with B, then C with D. Round 2 merges ends 4, 7 with 5, 8, 3 comparisons. That is 5 in all.

if you chose another

  • 4 is the drawing's order, ends 4, 5, 7, 8; the sort meets them as typed, 4, 7, 5, 8.
  • That counts only the checks after the sort, one for each activity after the first.
  • That counts round 2 as 4, but the last activity follows with no comparison.

new numbersthe test page's numbers

question 2

Which list makes the sort compare the fewest times?

the answer, and why

the answer is B

The sort compares 6 times on 0-1, 1-4, 0-5, 0-6, 1-2, the fewest of the four.

if you chose another

  • On that list it compares 9 times, more than 6.
  • On that list it compares 9 times, more than 6.
  • On that list it compares 8 times, more than 6.

new numbersthe test page's numbers