Presentation on theme: "Discrete Mathematics for Computer Scientists Anna Bretscher and Richard Pancer SY110Bretscher Fridays 10:10-12pm SY110Pancer Fridays 13:10-14pm Welcome."— Presentation transcript:
Discrete Mathematics for Computer Scientists Anna Bretscher and Richard Pancer SY110Bretscher Fridays 10:10-12pm SY110Pancer Fridays 13:10-14pm Welcome to CSCA67
Evaluation Assignments –4 each worth 10% –Late assignments will be accepted up to 24 hrs late with a penalty of 25% –You are encouraged to discuss the problems with other students however, the actual write up must be an individual effort –You must be able to reproduce any solution that you submit. The penalty for cheating ranges from a zero on the assignment to suspension from the university
Evaluation Term Test –Week 7 or 8 worth 20% Final Exam –Worth 40%
Resources Course Slides Posted each week. Print them and bring to class. Website Check the announcements daily. Textbook Stein, Drysdale and Bogart, Discrete Mathematics for Computer Scientists Office Hours Tutorials 4
Course Expectations Expectations of the lecturer Give clear, organized lectures Assign fair, challenging assignments that ensure that you, the student, understand the material Be available for help in office hours Help every student achieve their goals in the course (this requires your help!)
Course Expectations Expectations of the student Attend lectures and participate Bring course notes to class Review lecture notes after each class, not just before the exam Complete homework fully, neatly and independently Have respect for your classmates and lecturers
Course Expectations What does neatly mean? Staple sheets Write legibly (if you are incapable of this skill, please type) Your work should be of a quality that you would feel comfortable giving to your boss in a work environment.
Discrete Mathematics Who needs it? Anyone in computer science or a mathematical science Why? In CS we need to be able to speak precisely without ambiguity analyze problems and formulate solutions apply the concepts associated with probability, graph theory and counting theory.
CS is Applied Mathematics! Specifically, we will work on: –Thinking abstractly –Expressing ourselves precisely –Arguing logically – i.e., inferring conclusions that necessarily result from assumptions –Writing rigorous solutions –Learning how mathematics and computer science work together
Where Does Mathematics Appear in Computer Science? Computer GraphicsMultivariable calculus, physics- based modelling Digital Signal Processing Multivariable calculus, (eg., speech understanding) Numerical AnalysisMultivariable calculus, linear algebra CryptographyNumber theory Networking AlgorithmsGraph theory, statistics, combinatorics, probability, set theory
Where Does Mathematics Appear in Computer Science? DatabasesSet theory, logic Artificial IntelligenceSet theory, logic Programming Languages Set theory, logic Formal MethodsSet theory, logic for the specification and verification of hardware and software; (e.g., nuclear, aviation – NASA!)
Course Outline Proofs 3 weeks Graph Theory 3 weeks Counting 3 weeks Probability 2 weeks
How Do I Become Good At This Stuff? Same way that you become a good hockey player, calculus student, violinist… practice, practice, practice...
14 Weighted Job Scheduling Problem Given a set of jobs where each job has a value or weight jobs have a start time and duration Schedule the jobs so that the total value is maximized scheduled jobs do not overlap Q. What are some examples of this type of problem? A. printer queue, airplanes on runway, server use, scheduling surgeries…
15 Some Examples Time
Some Examples Time
17 Finding an Algorithm Q. What is an algorithm? A. A step-by-step procedure for solving a problem or accomplishing some end especially by a computer. * Lets list some potential algorithms to try: Earliest start time. * Merrian-Webster Time
18 Potential Algorithms Largest weight first. Other ideas? Time
19 Potential Algorithms Create all possible orders by largest weight first. Eg. Option 1: Pick 25. Option 2: Pick 16. Pick 10. Pick 3. Total = 29. Time Q. Does this work? A. Now Option 2 is Pick 16. Pick 11. Total =
20 So...Whats the Answer? Use a mathematical tool called Dynamic Programming. You can read about it in a text such as Algorithm Design by Kleinberg and Tardos. Or visit this link: programming-2x2.pdf Or take CSCC73.
21 A Simpler Problem Interval Scheduling Problem Given a set of jobs where jobs have a start time and finish time Schedule the jobs so that the number of jobs scheduled is maximized jobs do not overlap Notation J : The set of jobs j i : The i th job s i : The start time of the i th job f i : The finish time of the i th job
22 Scheduling The Jobs What is our algorithm? Example j1j1 j2j2 j3j3 j4j4 j5j5 j6j6 j7j7 Challenge First person to come up with a correct algorithm wins chocolate.
23 Scheduling The Jobs What is our algorithm? Sort the jobs by increasing start time. Schedule each job if there are no conflicts. Example j1j1 j2j2 j3j3 j4j4 j5j5 j6j6 j7j7 Ordering j 1, j 3, j 6, j 4, j 7, j 2, j 5 Schedule j 1, j 7, j 5
24 Scheduling The Jobs What is our algorithm? Sort the jobs by increasing start time. Schedule each job if there are no conflicts. j1j1 j2j2 j3j3 j4j4 j5j5 j6j6 j7j7 Ordering j 1, j 3, j 6, j 4, j 7, j 2, j 5 Schedule j1j1 Does this algorithm always find the best solution?
25 Scheduling The Jobs Other ideas? Ordering Schedule Does this algorithm always find the best solution?
26 Scheduling The Jobs What is our algorithm? Sort the jobs by increasing finish time. Schedule each job if there are no conflicts. Example j1j1 j2j2 j3j3 j4j4 j5j5 j6j6 j7j7 Ordering j 3, j 6, j 1, j 7, j 4, j 2, j 5 Schedule j 3, j 7, j 5
27 Is It Correct? Q. How do we know our algorithm is correct? A. Prove it! One common proof technique is Proof by Contradiction Idea Play Devils Advocate Assume our solution is not the best This means there is a better solution B Show that our algorithms solution is as good as B by making B equivalent to our solution.
28 The Proof Let S be the schedule our algorithm creates. S = (s 1, s 2, s 3,..., s n ) Let B be a better solution. B = (b 1, b 2, b 3,..., b m ) Q. What do we know about m and n? A. m >= n Q. What do we know about b 1 and s 1 ? A. The finish time for s 1 is less than or equal to the finish time for b 1. in order of non- decreasing finish time
29 The Proof S = (s 1, s 2, s 3,..., s n ) B = (b 1, b 2, b 3,..., b m ) Q. If the finish time for s 1 is less then or equal to the finish time for b 1, what can we say about B* = (s 1, b 2, b 3,..., b m )? A. |B*| = |B|. So B* is as good a solution as B but is more similar to S. Q. How should the proof finish? A. Repeat the argument with S = (s 2, s 3,…, s n ) and B = (b 2, b 3,…, b m ). Q. Why does this work? A. Induction - more on this later.
30 Challenge Another Scheduling Problem Given a set of employees, want to set up a meeting that everyone can attend. Each person has a calendar which says whether they are available for any given time slot during the day. Give an efficient algorithm to schedule the meeting so that everyone can attend (if possible).