1 / 21

Welcome to Cpt S 450 Design and Analysis of Algorithms Syllabus and Introduction

Welcome to Cpt S 450 Design and Analysis of Algorithms Syllabus and Introduction. CptS 450 Design and Analysis of Algorithms Spring 2014 Instructor: John Miller, West 134E jhmiller@tricity.wsu.edu Class web page can be found at http://www.tricity.wsu.edu/~jhmiller. Objectives:

quant
Download Presentation

Welcome to Cpt S 450 Design and Analysis of Algorithms Syllabus and Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Welcome to Cpt S 450 Design and Analysis of Algorithms Syllabus and Introduction

  2. CptS 450 Design and Analysis of Algorithms Spring 2014 Instructor: John Miller, West 134E jhmiller@tricity.wsu.edu Class web page can be found at http://www.tricity.wsu.edu/~jhmiller

  3. Objectives: To present the mathematical basis for quantitative analysis of algorithms. To introduce students to various types of algorithms and analysis techniques Textbook: “Introduction to Algorithms” 3th Edition by Corman, et al Course content: Chapters 1-2: Introduction Chapter 3: Growth of functions Chapter 4: Solving recurrences Midterm exam Chapter 5: Probabilistic analysis Selected topics from the following: Chapters 6-9: Sorting algorithms Chapters 15-17: Advanced design and analysis techniques Chapters 22-26: Graph algorithms Final exam

  4. Required assignments: Prior approval is required for late submission homework assignments. No partial credit on homework. Full credit for corrected homework. Criteria for student evaluation: homework 25%, quizzes 25%, midterm exam 25%, final exam 25%.

  5. Academic integrity: Academic integrity will be strongly enforced in this course. Any student caught cheating on any assignment will be given an F grade for the course and will be reported to the Office Student Standards and Accountability. Cheating is defined in the Standards for Student Conduct WAC 504-26-010 (3). It is strongly suggested that you read and understand these definitions: http://www.studentmediagroup.com/planners/palouse2012/#/18/ I encourage you to work with classmates on assignments. However, each student must turn in original work. No copying will be accepted. Students who violate WSU’s Standards of Conduct for Students will receive an F as a final grade in this course, will not have the option to withdraw from the course and will be reported to the Office Student Standards and Accountability. Cheating is defined in the Standards for Student Conduct WAC 504-26-010 (3). It is strongly suggested that you read and understand these definitions: http://www.studentmediagroup.com/planners/palouse2012/#/18/ Academic integrity is the cornerstone of the university. Any student who attempts to gain an unfair advantage over other students by cheating, will fail the assignment and be reported to the Office Student Standards and Accountability. Cheating is defined in the Standards for Student Conduct WAC 504-26-010 (3). http://www.studentmediagroup.com/planners/palouse2012/#/18/

  6. Campus Safety Statement WSU Tri-Cities is committed to maintaining a safe environment for its faculty, staff and students. The Campus Safety Plan can be found at http://www.tricity.wsu.edu/safetyplan/ See also the WSU Office of Emergency Management site at http://oem.wsu.edu/emergencies Up-to-date WSU emergency alerts are available at http://alert.wsu.edu/ Disability Services Reasonable Accommodations Statement: Reasonable accommodations are available for students who have a documented disability. Classroom accommodation forms are available through the Disability Services Office. If you have a documented disability, even if it’s temporary, make an appointment as soon as possible with the Disability Services Coordinator, Cherish Tijerina Pearson, West Building, Room 269J, at 372-7352 or ctijerina@tricity.wsu.edu.You will need to provide your instructor with the appropriate classroom accommodation form. The form should be completed and submitted during the first week of class. Late notification can delay your accommodations or cause them to be unavailable. All accommodations for disabilities must be approved through the Disability Services Coordinator.

  7. Big picture of algorithm analysis Algorithm is sequence of operations that transforms input to output Example: input sequence (a1, a2, … aN) output some permutations that is sorted Total algorithm analysis includes a. memory and storage requirements b. numerical precision c. correctness d. efficiency (execution time for given input size) We focus on almost entirely on efficiency Requires model of implementation: assume sequential Base analysis on pseudocode a. see text pp20-22 for conventions b. indents show structure c. loop counter one more than bound on exit

  8. Primary interest is “order of growth” Linear runtime: T(n) = a + bn order of growth: Q(n) Quadratic : T(n) = a + bn + cn2 order of growth: Q(n2) Logarithmic: T(n) = anlg(bn) order of growth: Q(nlg(n)) Coefficients hard to calculate and not in “order of growth” Issues of input other than size a. most often interested in worst-case scenario: yields upper bound b. often average run time has same order of growth as worst case c. sometimes calculate average run time based on assumption of random input of fixed size Line-by-line analysis of insertion sort

  9. Note: indent shows that 8 in not part of while loop Worst case tj = j

  10. Proof that is an example of “induction on integers” Standard form is Basis: true for n=n0 Induction: if S(n) then S(n+1) Here we use Induction: if S(n-1) then S(n) Equally valid

  11. Use the arithmetic sum to evaluate the sums in the analysis of insertion sort runtime

  12. Worst-case scenario: must compare aj to every element in A[1…j-1] tj = j When would this happen? (See slide #8, example d, tj = j -1?)

  13. Line-by-line analysis of insertion sort Note: All quadratic terms come from analysis of “while” statement Collect terms: T(n) = a + bn + cn2 (was algebra really necessary?) This is upper bound that occur (i.e. worst case) In notation of Chapter 3, T(n) = O(n2)

  14. Loop invariant and correctness Loop invariant = statement about iterative pseudo-code To prove that the statement is true by induction we need Initialization: true before 1st iteration Maintenance: if true on ith iteration, also true on i+1 Termination: truth shows that the algorithm is correct

  15. Application of loop invariant to insertion sort

  16. Recursive sorting algorithm Divide-and-conquer phase: Recursively divide the problem into smaller pieces until get a solution by default Execution phase: Given default solution, assemble the full solution from successively larger pieces For efficiency analysis, consider execution phase only Example of execution phase for input (5, 2, 4, 7, 1, 3, 2, 6)

  17. Cost of merging 2 sorted arrays containing a total of n elements Heuristic analysis: Consider 2 sorted card decks face up decks not necessarily of equal size Compare size of cards showing Place smaller face down on 3rd stack If one deck is empty place other on 3rd stack How many comparison must be made? How many comparison must be made, worst case? Why is it important that decks be sorted?

  18. Cost of merging 2 sorted decks containing a total of n elements using sentinel cards Add sentinel card to bottom of each sorted deck Value of sentinel card is infinite How many comparison must be made to merge decks? Does use of sentinel cards increase runtime? Express runtime as “recurrence” for even number of cards T(n) = 2 if n = 2 T(n) = 2T(n/2) + n if n = 2k with k>1 n is the cost of merging the 2 sorted decks (overhead)

  19. Analysis of merge sort by trees All 3 trees are equally valid but not equally useful Smallest tree implies T(n) = 2T(n/2) + cn This expresses the run time as a recursive relationship The largest tree enables a solution to the recursion T(n) = cn[lg(n) + 1] General methods to solve recursions are discussed in Chapter 4 n/2istop = 1 How do we derive this number of levels? What is the order of growth?

  20. CptS 450 Spring 2014 [All problems are from Cormen et al, 3rd Edition] Homework Assignment 1: due 1/17/14 1. ex 2.3-1 p 37 2. ex 2.3-3 p 39 3. ex.2.3-4 p 39

  21. Hints on ex 2.3-3 If n=2k, then n/2 = 2k-1 Recurrence becomes T(2) = 2 if k=1 T(2k) = 2T(2k-1) + 2k if k>1 Basis: true for k=1? Induction: If S(k-1) then S(K)

More Related