Presentation on theme: "Welcome to CSCA67 Discrete Mathematics for Computer Scientists"— Presentation transcript:
1Welcome to CSCA67 Discrete Mathematics for Computer Scientists Anna Bretscher and Richard PancerSY110 Bretscher Fridays 10:10-12pmSY110 Pancer Fridays 13:10-14pm
2Evaluation 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 effortYou 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
3EvaluationTerm TestWeek 7 or 8 worth 20%Final ExamWorth 40%
4ResourcesCourse 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
5Course Expectations Expectations of the lecturer Give clear, organized lecturesAssign fair, challenging assignments that ensure that you, the student, understand the materialBe available for help in office hoursHelp every student achieve their goals in the course (this requires your help!)
6Course Expectations Expectations of the student Attend lectures and participateBring course notes to classReview lecture notes after each class, not just before the examComplete homework fully, neatly and independentlyHave respect for your classmates and lecturers
7Course 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.
8Discrete Mathematics Who needs it? Anyone in computer science or a mathematical scienceWhy?In CS we need to be able tospeak precisely without ambiguityanalyze problems andformulate solutionsapply the concepts associated with probability, graph theory and counting theory.
9CS is Applied Mathematics! Specifically, we will work on:Thinking abstractlyExpressing ourselves preciselyArguing logically – i.e., inferring conclusions that necessarily result from assumptionsWriting rigorous solutionsLearning how mathematics and computer science work together
10Where Does Mathematics Appear in Computer Science? Computer GraphicsMultivariable calculus, physics-based modellingDigital Signal ProcessingMultivariable calculus, (eg., speech understanding)Numerical AnalysisMultivariable calculus, linear algebraCryptographyNumber theoryNetworking AlgorithmsGraph theory, statistics, combinatorics, probability, set theory
11Where Does Mathematics Appear in Computer Science? DatabasesSet theory, logicArtificial IntelligenceProgramming LanguagesFormal MethodsSet theory, logic for the specification and verification of hardware and software; (e.g., nuclear, aviation – NASA!)
12Course Outline Proofs 3 weeks Graph Theory Counting Probability
13How Do I Become Good At This Stuff? Same way that you become a good hockey player, calculus student, violinist…practice, practice, practice...
14Weighted Job Scheduling ProblemGiven a set of jobs whereeach job has a value or weightjobs have a start time and durationSchedule the jobs so thatthe total value is maximizedscheduled jobs do not overlapQ. What are some examples of this type of problem?A. printer queue, airplanes on runway, server use, scheduling surgeries…
17Finding 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.*Let’s list some potential algorithms to try:Earliest start time.Time105163* Merrian-Webster
18Potential Algorithms Largest weight first. Other ideas? Time 25 10 16 3Time
19Potential AlgorithmsCreate all possible orders by largest weight first.Eg. Option 1: Pick 25.Option 2: Pick 16. Pick 10. Pick 3. Total = 29.Time102516311Q. Does this work?A. Now Option 2 is Pick 16. Pick 11. Total = 27.
20So...What’s 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.pdfOr take CSCC73.
21A Simpler Problem Interval Scheduling Problem Given a set of jobs wherejobs have a start time and finish timeSchedule the jobs so thatthe number of jobs scheduled is maximizedjobs do not overlapNotationJ: The set of jobsji: The ith jobsi: The start time of the ith jobfi: The finish time of the ith job
22Scheduling The Jobs Challenge What is our algorithm? Example Let students work for a few minutes. Ask them to get their neighbour to try and find a counterexample. Remind them what a counterexample is. Explain what is meant by “general” - ie, works for more than just the given example, works for all cases.ChallengeFirst person to come up with a correct algorithm wins chocolate.
23Scheduling The Jobs What is our algorithm? Example Ordering Schedule Sort the jobs by increasing start time. Schedule each job if there are no conflicts.Examplej1j2j3j4j5j6j7Some students may suggest trying the job with earliest start time.Orderingj1, j3, j6, j4, j7, j2, j5Schedulej1, j7, j5
24Scheduling The Jobs What is our algorithm? Sort the jobs by increasing start time. Schedule each job if there are no conflicts.Does this algorithm always find the best solution?j2j1j3j4j5j6j7Now show that this doesn’t always give the optimal answer.Orderingj1, j3, j6, j4, j7, j2, j5Schedulej1
25Scheduling The Jobs Other ideas? Does this algorithm always find the best solution?Some students may say by shortest duration - show that this doesn’t always work as well. simple example is two long jobs consecutively and one short one that overlaps a little with each of the other two. If they say something else, get the class to decide if there is a counter example.OrderingSchedule
26Scheduling The Jobs What is our algorithm? Example Ordering Schedule Sort the jobs by increasing finish time. Schedule each job if there are no conflicts.Examplej1j2j3j4j5j6j7Now show an algorithm that does always find the optimal.Orderingj3, j6, j1, j7, j4, j2, j5Schedulej3, j7, j5
27Is It Correct? Q. How do we know our algorithm is correct? A. Prove it!One common proof technique is “Proof by Contradiction”IdeaPlay Devil’s AdvocateAssume our solution is not the bestThis means there is a better solution BShow that our algorithm’s solution is as good as B by making B equivalent to our solution.Point out that in previous cases we were able to disprove algorithms by giving a counter example. How do we know that a counter example doesn’t exist? perhaps we just haven’t thought of a good one yet...this is why we need to prove that our solution is the best possible.
28The Proof Let S be the schedule our algorithm creates. S = (s1, s2, s3, ... , sn)Let B be a better solution.B = (b1, b2, b3, ... , bm)Q. What do we know about m and n?A. m >= nQ. What do we know about b1 and s1?A. The finish time for s1 is less than or equal to the finish time for b1.in order of non-decreasing finish time
29The Proof S = (s1, s2, s3, ... , sn) B = (b1, b2, b3, ... , bm) Q. If the finish time for s1 is less then or equal to the finish time for b1, what can we say about B* = (s1, b2, b3, ... , bm)?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’ = (s2, s3,…, sn) and B’ = (b2, b3,…, bm).Q. Why does this work?A. Induction - more on this later.
30Challenge 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).