Link¨opings universitet Institutionen f¨or datavetenskap / Matematiska institutionen

advertisement

Link¨opings universitet

Institutionen f¨or datavetenskap / Matematiska institutionen

Hans Ols´en / Kaj Holmberg

Tentamen

TDDB56 DALGOPT-D Algoritmer och Optimering

23 April 2003, kl 8-13

Preliminary solutions, DALG-part

2.

a) 3 b) 1, 4 c) 3

4.

a) O ( n log n ) b) O ( n 2 ) c) From the assymptotic complexities, the answer is “no”.

6.

a) The graph is shown in Fig 1. below. It is a directed acyclic graph.

b) Use topological sort. The numbering 1-9 in Fig 2. shows a possible ordering of the courses to be taken by Tina.

c) The graph describes a partial ordering: x > y if there exists a path from x to y .

Courses which are not ordered can be taken in parallel, but courses on the same path cannot be taken in the same term. The number of courses on the longest path

1

8.

therefore determines the number of terms needed as a minimum to schedule all courses. Breadth first search can be used for the scheduling.

In this case the longest path has four courses and the schedule may look as follows:

Term 1: A, D

Term 2: C, E

Term 3: H, F, G

Term 4: B, I

2

Download