Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

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 prerequisite. Sometimes enthusiasm alone is not enough. CSci 1311: Discrete Structures I (3) CSci 1112: Algorithms and Data Structures (3)

2 Official Course Description http://www.cs.gwu.edu/academics/courses/graduate/csci- 6212 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 and spring) Textbook: Introduction to Algorithms, Cormen, Leiserson, Rivest, and Stein.

3 Basic Principles of Algorithm Design and Analysis

4 Algorithm Design

5 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

6 Example: Sorting an Array of integers 5 5 2 2 4 4 6 6 1 1 3 3

7 5 5 2 2 4 4 6 6 1 1 3 3

8 5 5 2 2 4 4 6 6 1 1 3 3

9 5 5 2 2 4 4 6 6 1 1 3 3

10 5 5 2 2 4 4 6 6 1 1 3 3

11 5 5 2 2 4 4 6 6 1 1 3 3

12 5 5 2 2 4 4 6 6 1 1 3 3

13 5 5 2 2 4 4 6 6 1 1 3 3

14 5 5 2 2 4 4 6 6 1 1 3 3

15 5 5 2 2 4 4 6 6 1 1 3 3

16 5 5 2 2 4 4 6 6 1 1 3 3

17 5 5 2 2 4 4 6 6 1 1 3 3

18 5 5 2 2 4 4 6 6 1 1 3 3

19 5 5 2 2 4 4 6 6 1 1 3 3

20 5 5 2 2 4 4 6 6 1 1 3 3

21 5 5 2 2 4 4 6 6 1 1 3 3

22 5 5 2 2 4 4 6 6 1 1 3 3

23 5 5 2 2 4 4 6 6 1 1 3 3

24 5 5 2 2 4 4 6 6 1 1 3 3

25 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.

26 Accept Concise Notation 5 5 2 2 4 4 6 6 1 1 3 3

27 524613

28 Disambiguate it 524613,,,,,

29 Abstract it 524613,,,,, A = { }

30 Denote it Insertion Sort (A) 1 for j = 2 to A.length 2 key = A[j] 3// Insert A[j] into the sorted sequence A[1..j-1] 4i = j - 1 5while i > 0 and A[i] > key 6A[i +1] = A[i] 7i = i - 1 8A[i + 1] = key

31 Pascal Notation Insertion Sort (A) 1 for j = 2 to A.length 2 begin 3 key = A[j] 4// Insert A[j] into the sorted sequence A[1..j-1] 5i = j - 1 6while i > 0 and A[i] > key 7begin 8A[i +1] = A[i] 9i = i - 1 10end 11A[i + 1] = key 12 end

32 C Notation Insertion Sort (A) 1 for j = 2 to A.length 2 { 3 key = A[j] 4// Insert A[j] into the sorted sequence A[1..j-1] 5i = j - 1 6while i > 0 and A[i] > key 7{ 8A[i +1] = A[i] 9i = i - 1 10} 11A[i + 1] = key 12 }

33 Algorithm Analysis

34 Example: Running (Execution) Time Analysis Insertion Sort (A) 1 for j = 2 to A.length 2 key = A[j] 3// Insert A[j] into the sorted sequence A[1..j-1] 4i = j - 1 5while i > 0 and A[i] > key 6A[i +1] = A[i] 7i = i - 1 8A[i + 1] = key

35 How many times does each statement execute ? Insertion Sort (A) 1 for j = 2 to A.length 2 key = A[j] 3// Insert A[j] into the sorted sequence A[1..j-1] 4i = j - 1 5while i > 0 and A[i] > key 6A[i +1] = A[i] 7i = i - 1 8A[i + 1] = key

36 Factors to Consider Input Size Running Time Worst-Case Best-Case Average Rate of Growth

37 Assumptions Technologies Memory Model: RAM (Random Access Machine/Memory) Processor: Single Processor


Download ppt "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."

Similar presentations


Ads by Google