+ All Categories
Home > Documents > CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please...

CSCI 6212 Design and Analysis of Algorithms Dr. Juman Byun The George Washington University Please...

Date post: 13-Dec-2015
Category:
Upload: stewart-hudson
View: 221 times
Download: 2 times
Share this document with a friend
Popular Tags:
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 prerequisite. Sometimes enthusiasm alone is not enough. CSci 1311: Discrete Structures I (3) CSci 1112: Algorithms and Data Structures (3)
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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

Assumptions

• Technologies

• Memory Model: RAM (Random Access Machine/Memory)

• Processor: Single Processor


Recommended