csci 6212 design and analysis of algorithms dr. juman byun the george washington university please...
TRANSCRIPT
![Page 1: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/1.jpg)
CSCI 6212Design and Analysis of
Algorithms
Dr. Juman ByunThe George Washington University
Please drop this course if you have not taken the following prerequisite.
Sometimes enthusiasm alone is not enough.
• CSci 1311: Discrete Structures I (3)• CSci 1112: Algorithms and Data Structures
(3)
![Page 2: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/2.jpg)
Official Course Description
• http://www.cs.gwu.edu/academics/courses/graduate/csci-6212
• Design and analysis of algorithms. Turing machines; NP-Complete theory. Algorithmic techniques: divide-and-conquer, greedy, dynamic programming, graph traversal, backtracking, and branch-and-bound. Applications include sorting and searching, graph algorithms, and optimization. Prerequisite: CSci 1311, 1112. (Fall andspring)
• Textbook: Introduction to Algorithms, Cormen, Leiserson, Rivest, and Stein.
![Page 3: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/3.jpg)
Basic Principles of Algorithm Design and
Analysis
![Page 4: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/4.jpg)
Algorithm Design
![Page 5: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/5.jpg)
How to Start the Design ?
• Understand the problem. What are we trying to achieve ?
• Get a rough idea how to solve the problem using your intuition and imagination
![Page 6: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/6.jpg)
Example: Sorting an Array of integers
55 22 44 66 11 33
![Page 7: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/7.jpg)
Example: Sorting an Array of integers
55
22 44 66 11 33
![Page 8: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/8.jpg)
Example: Sorting an Array of integers
5522
44 66 11 33
![Page 9: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/9.jpg)
Example: Sorting an Array of integers
5522
44 66 11 33
![Page 10: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/10.jpg)
Example: Sorting an Array of integers
552244
66 11 33
![Page 11: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/11.jpg)
Example: Sorting an Array of integers
5522 44
66 11 33
![Page 12: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/12.jpg)
Example: Sorting an Array of integers
5522 4466
11 33
![Page 13: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/13.jpg)
Example: Sorting an Array of integers
5522 44 66
11 33
![Page 14: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/14.jpg)
Example: Sorting an Array of integers
5522 44 6611
33
![Page 15: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/15.jpg)
Example: Sorting an Array of integers
5522 44 6611
33
![Page 16: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/16.jpg)
Example: Sorting an Array of integers
5522 44 6611
33
![Page 17: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/17.jpg)
Example: Sorting an Array of integers
5522 44 6611
33
![Page 18: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/18.jpg)
Example: Sorting an Array of integers
5522 44 6611
33
![Page 19: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/19.jpg)
Example: Sorting an Array of integers
5522 44 6611
33
![Page 20: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/20.jpg)
Example: Sorting an Array of integers
5522 44 661133
![Page 21: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/21.jpg)
Example: Sorting an Array of integers
5522 44 661133
![Page 22: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/22.jpg)
Example: Sorting an Array of integers
5522 44 661133
![Page 23: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/23.jpg)
Example: Sorting an Array of integers
5522 44 661133
![Page 24: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/24.jpg)
Example: Sorting an Array of integers
5522 44 6611 33
![Page 25: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/25.jpg)
Accept Concise Notation
• The previous colorful animation was pretty but it took me a some time to create it.
• In order for a human being to perceive the entire problem, you need to compress the problem or commit it into the long-term storage of your brain.
• Algorithmic notation is an excellent way of compressing a problem so that it is easier to remember and handle.
![Page 26: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/26.jpg)
Accept Concise Notation
55 22 44 66 11 33
![Page 27: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/27.jpg)
Accept Concise Notation
5 2 4 6 1 3
![Page 28: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/28.jpg)
Disambiguate it
5 2 4 6 1 3, , , , ,
![Page 29: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/29.jpg)
Abstract it
5 2 4 6 1 3, , , , ,A = { }
![Page 30: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/30.jpg)
Denote it
Insertion Sort (A)1 for j = 2 to A.length2 key = A[j]3 // Insert A[j] into the sorted sequence A[1..j-1]4 i = j - 15 while i > 0 and A[i] > key6 A[i +1] = A[i]7 i = i - 18 A[i + 1] = key
![Page 31: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/31.jpg)
Pascal NotationInsertion Sort (A)1 for j = 2 to A.length2 begin3 key = A[j]4 // Insert A[j] into the sorted sequence A[1..j-1]5 i = j - 16 while i > 0 and A[i] > key7 begin8 A[i +1] = A[i]9 i = i - 110 end11 A[i + 1] = key12 end
![Page 32: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/32.jpg)
C NotationInsertion Sort (A)1 for j = 2 to A.length2 {3 key = A[j]4 // Insert A[j] into the sorted sequence A[1..j-1]5 i = j - 16 while i > 0 and A[i] > key7 {8 A[i +1] = A[i]9 i = i - 110 }11 A[i + 1] = key12 }
![Page 33: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/33.jpg)
Algorithm Analysis
![Page 34: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/34.jpg)
Example: Running (Execution) Time Analysis
Insertion Sort (A)1 for j = 2 to A.length2 key = A[j]3 // Insert A[j] into the sorted sequence A[1..j-1]4 i = j - 15 while i > 0 and A[i] > key6 A[i +1] = A[i]7 i = i - 18 A[i + 1] = key
![Page 35: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/35.jpg)
How many times does each statement execute ?
Insertion Sort (A)1 for j = 2 to A.length2 key = A[j]3 // Insert A[j] into the sorted sequence A[1..j-1]4 i = j - 15 while i > 0 and A[i] > key6 A[i +1] = A[i]7 i = i - 18 A[i + 1] = key
![Page 36: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/36.jpg)
Factors to Consider• Input Size
• Running Time
• Worst-Case
• Best-Case
• Average
• Rate of Growth
![Page 37: CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please drop this course if you have not taken the following](https://reader035.vdocument.in/reader035/viewer/2022062515/56649f455503460f94c67797/html5/thumbnails/37.jpg)
Assumptions
• Technologies
• Memory Model: RAM (Random Access Machine/Memory)
• Processor: Single Processor