Algorithms and Datastructures
Runtime analysis Minsort / Heapsort, Induction
Albert-Ludwigs-Universität Freiburg
- Prof. Dr. Rolf Backofen
Algorithms and Datastructures Runtime analysis Minsort / Heapsort, - - PowerPoint PPT Presentation
Algorithms and Datastructures Runtime analysis Minsort / Heapsort, Induction Albert-Ludwigs-Universitt Freiburg Prof. Dr. Rolf Backofen Bioinformatics Group / Department of Computer Science Algorithms and Datastructures, October 2018
Albert-Ludwigs-Universität Freiburg
October 2018
2 / 47
October 2018
4 / 47
October 2018
5 / 47
October 2018
7 / 47
October 2018
8 / 47
October 2018
10 / 47
October 2018
11 / 47
50 100 150 200 250 300 350 4 8 2 6 10
C2 =7/2 could have been larger or small (exact value not relevant) C1=1/2 could have been choosen smaller (not relevant), but not larger
October 2018
12 / 47
1 2 3 12 7 4 6 10 8 15 14 5 11 9 13
October 2018
13 / 47
14 / 47
def minsort ( elements ) : f o r i in range (0 , len ( elements ) −1) : minimum = i f o r j in range ( i +1 , len ( elements ) ) : i f elements [ j ] < elements [ minimum ] : minimum = j i f minimum != i : elements [ i ] , elements [ minimum ] = \ elements [ minimum ] , elements [ i ] return elements
October 2018
15 / 47
October 2018
16 / 47
October 2018
18 / 47
October 2018
19 / 47
October 2018
20 / 47
October 2018
22 / 47
Root Leaves
October 2018
23 / 47
October 2018
25 / 47
October 2018
26 / 47
Root
October 2018
27 / 47
October 2018
29 / 47
October 2018
30 / 47
Depth 4 → 23 nodes Depth 3 → 22 nodes Depth 2 → 21 nodes Depth 1 → 20 nodes Depth d → 2d−1 nodes Generally:
October 2018
31 / 47
October 2018
32 / 47
October 2018
33 / 47
October 2018
35 / 47
October 2018
36 / 47
October 2018
37 / 47
October 2018
38 / 47
October 2018
39 / 47
October 2018
41 / 47
October 2018
42 / 47
October 2018
44 / 47
October 2018
45 / 47
October 2018
46 / 47
October 2018
47 / 47