Algorithms and Data Structures II Course Notes - Analysis & Techniques

Telechargé par Jawhara Guerraoui
Algorithms and Data Structures II Course Notes - Analysis &
Techniques
Analysis Of Algorithms I (George Mason University)
Scan to open on Studocu
Studocu is not sponsored or endorsed by any college or university
Algorithms and Data Structures II Course Notes - Analysis &
Techniques
Analysis Of Algorithms I (George Mason University)
Scan to open on Studocu
Studocu is not sponsored or endorsed by any college or university
Downloaded by jfaf zwiwn ([email protected])
lOMoARcPSD|59007211
Algorithms and Data Structures II
Course Notes
Felipe Balbi
April 23, 2022
Downloaded by jfaf zwiwn ([email protected])
lOMoARcPSD|59007211
Contents
Week 1 5
1.001 What is analysis of algorithms? . . . . . . . . . . . . . . . . . . . . . . . . 5
1.002 What is analysis of algorithms? . . . . . . . . . . . . . . . . . . . . . . . . 6
1.004 How to measure/estimate time and space requirements . . . . . . . . . . 6
1.006TheRAMmodel................................ 7
1.007TheRamModel ................................ 8
1.009 Counting up time and space units, part 1 . . . . . . . . . . . . . . . . . . 8
1.010 Counting up time and space units, part 2 . . . . . . . . . . . . . . . . . . 8
1.011 Counting up time and space units . . . . . . . . . . . . . . . . . . . . . . 9
1.101 Growth of functions, part 1 . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.103 Growth of functions, part 2 . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.105 Growth of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.106 Faster computer versus faster algorithm . . . . . . . . . . . . . . . . . . . 13
1.108 Faster computer versus faster algorithm . . . . . . . . . . . . . . . . . . . 14
Week 2 15
1.201 Worst and best cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.202 Worst and average cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.301 Introduction to asymptotic analysis . . . . . . . . . . . . . . . . . . . . . 15
1.303 Big-Onotation................................. 16
1.305Omeganotation ................................ 17
1.307Thetanotation................................. 19
1.309Asymptoticnotation.............................. 20
Week 3 21
2.001 Introduction to recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.002 The structure of recursive algorithms . . . . . . . . . . . . . . . . . . . . 21
2.004 Tracing a recursive algorithm . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.101 From iteration to recursion . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.103 Writing a recursive algorithm, part 1 . . . . . . . . . . . . . . . . . . . . . 23
2.104 Writing a recursive algorithm, part 2 . . . . . . . . . . . . . . . . . . . . . 23
Week 4 25
2.201 Time complexity of recursive algorithms . . . . . . . . . . . . . . . . . . . 25
2.203 Solving recurrence equations . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.301Themastertheorem.............................. 26
2.303 Recursive algorithms and their analysis . . . . . . . . . . . . . . . . . . . 27
2
Downloaded by jfaf zwiwn ([email protected])
lOMoARcPSD|59007211
Contents
Week 5 28
3.001 Comparison and non comparison sorting algorithms . . . . . . . . . . . . 28
3.004 Bubble sort: Pseudocode . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.102 Insertion sort: Pseudocode . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.104Insertionsort.................................. 29
3.105 Selection sort: Pseudocode . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Week 6 31
3.202 Quicksort: Pseudocode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.204Quicksort.................................... 32
3.302 Mergesort: Pseudocode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.305Mergesort.................................... 33
Week 7 35
4.001 The limits of comparison sorts . . . . . . . . . . . . . . . . . . . . . . . . 35
4.002 Lower bounds for commparison sorts . . . . . . . . . . . . . . . . . . . . . 37
4.101 Counting sort: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.102 Counting sort: Pseudocode . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.104Countingsort.................................. 39
Week 8 40
4.201Radixsort ................................... 40
4.203Radixsort ................................... 40
4.301Bucketsort................................... 41
4.303Bucketsort................................... 43
Week 9 44
5.001Whatishashing? ............................... 44
5.003Hashtables................................... 45
5.101 Collisions in hash tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.103Hashing..................................... 48
Week 10 49
5.301EndofTopic5................................. 49
Week 13 50
7.001 Introduction to data structures . . . . . . . . . . . . . . . . . . . . . . . . 50
7.003 Linked lists: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.101 Linked lists: Insert operation . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.103 Linked lists: Delete operation . . . . . . . . . . . . . . . . . . . . . . . . . 53
7.105 Linked lists: Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
7.108Linkedlists................................... 55
Week 14 56
7.201 Stacks: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3
Downloaded by jfaf zwiwn ([email protected])
lOMoARcPSD|59007211
Contents
7.203: Stacks: Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
7.301 Queues: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.303 Queues: Array-based implementation . . . . . . . . . . . . . . . . . . . . 60
7.305 Queues: List-based implementation . . . . . . . . . . . . . . . . . . . . . 61
7.307Stacksandqueues ............................... 62
Week 15 64
8.001 Trees: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
8.003 Binary trees: Implementation . . . . . . . . . . . . . . . . . . . . . . . . . 66
8.101 Binary tree traversal: Introduction . . . . . . . . . . . . . . . . . . . . . . 67
8.102 Depth-first traversal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
8.104 Breadth-first traversal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Week 16 70
8.201 Binary search trees (BSTs) . . . . . . . . . . . . . . . . . . . . . . . . . . 70
8.203BST:Insert................................... 71
8.301BST:Search .................................. 71
8.303BST:Delete .................................. 72
8.305 Binary search trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Week 17 77
9.001 Heaps: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
9.003 Heaps: Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
9.005 Heaps: Insert (element by element) . . . . . . . . . . . . . . . . . . . . . 79
9.007 Insert: Deletion (extract maximum) . . . . . . . . . . . . . . . . . . . . . 82
9.101 Heaps: Build in place . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
9.103Heapsort .................................... 91
9.105 Heapsort’s complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
9.107 Heaps, heapsort and priority queues . . . . . . . . . . . . . . . . . . . . . 92
Week 19 93
10.001 Graphs: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
10.003 Graphs: Representations . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
10.005 Minimum spanning tree . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
10.007Prim’salgorithm ...............................102
10.101 Kruskal’s algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
10.103 Dijkstra’s algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
10.104 Dijkstra’s algorithm pseudocode . . . . . . . . . . . . . . . . . . . . . . . 109
10.106 Graph representation, MST and Dijkstra . . . . . . . . . . . . . . . . . . 109
4
Downloaded by jfaf zwiwn ([email protected])
lOMoARcPSD|59007211
1 / 111 100%
La catégorie de ce document est-elle correcte?
Merci pour votre participation!

Faire une suggestion

Avez-vous trouvé des erreurs dans l'interface ou les textes ? Ou savez-vous comment améliorer l'interface utilisateur de StudyLib ? N'hésitez pas à envoyer vos suggestions. C'est très important pour nous!