Courses βΈ± Algorithms

You can also access the quiz on Itempool here if you want to practice, or see the notes below for more context.

#### Lecture Recording

#### In-class Quiz Questions

These questions were about the activity selection problem, where we are given a collection of activities in terms of their start and end times , and the goal is to select a largest collection of non-overlapping activities, where two activities are said to overlap if their corresponding intervals intersect.

- The the most obvious rule might be to always select the available request that starts earliestβ that is, the one with minimal start time. Does this work?
- Yes,always
- No,never
- There exist examples on which the answer fails.

## Reveal answer

There exist examples on which the answer fails.

You can construct examples on which this works (an instance with only one activity, for examples) and ones on which this doesn't (e.g, the first request may block all others).

- Follow up strategy: start out by accepting the request that requires the smallest interval of time-namely, the request for which is as small as possible. Does this work?
- Yes,always
- No,never
- There exist examples on which the answer fails.

## Reveal answer

There exist examples on which the answer fails.

You can construct examples on which this works (an instance with only one activity, for examples) and ones on which this doesn't (e.g, one with three requests where a short request intersecting two large non-overlapping ones).

These questions were about the Islands War problem.

- What is the optimal answer for the example below?
- _____ (In class, you were asked to enter a number.)

## Reveal answer

1

The bridge (3,4) will work.

- What is the optimal answer for the example below?
- _____ (In class, you were asked to enter a number.)

## Reveal answer

2

The bridges (4,5) and (7,8) will work.

- If is the largest number of mutually disjoint requests and is the optimal answer, which of the following is true?
- Neither of the two
- Both [option wasn't available during class!]

## Reveal answer

Note that option (a) is

*also*true, so the correct answer is in fact (d); but at this point in the lecture the question was to identify the "obvious" inequality, which is the one in (b).Β