Download presentation

Presentation is loading. Please wait.

Published byTyson Lobley Modified over 2 years ago

1
**Welcome to CSCA67 Discrete Mathematics for Computer Scientists**

Anna Bretscher and Richard Pancer SY110 Bretscher Fridays 10:10-12pm SY110 Pancer Fridays 13:10-14pm

2
**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

3
Evaluation Term Test Week 7 or 8 worth 20% Final Exam Worth 40%

4
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

5
**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!)

6
**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

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

8
**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.

9
**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

10
**Where Does Mathematics Appear in Computer Science?**

Computer Graphics Multivariable calculus, physics-based modelling Digital Signal Processing Multivariable calculus, (eg., speech understanding) Numerical Analysis Multivariable calculus, linear algebra Cryptography Number theory Networking Algorithms Graph theory, statistics, combinatorics, probability, set theory

11
**Where Does Mathematics Appear in Computer Science?**

Databases Set theory, logic Artificial Intelligence Programming Languages Formal Methods Set theory, logic for the specification and verification of hardware and software; (e.g., nuclear, aviation – NASA!)

12
**Course Outline Proofs 3 weeks Graph Theory Counting Probability**

13
**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 10 5 16 3 Time

16
Some Examples 10 19 3 25 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.* Let’s list some potential algorithms to try: Earliest start time. Time 10 5 16 3 * Merrian-Webster

18
**Potential Algorithms Largest weight first. Other ideas? Time 25 10 16**

3 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 10 25 16 3 11 Q. Does this work? A. Now Option 2 is Pick 16. Pick 11. Total = 27.

20
So...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.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 ji: The ith job si: The start time of the ith job fi: The finish time of the ith job

22
**Scheduling 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. Challenge First person to come up with a correct algorithm wins chocolate.

23
**Scheduling The Jobs What is our algorithm? Example Ordering Schedule**

Sort the jobs by increasing start time. Schedule each job if there are no conflicts. Example j1 j2 j3 j4 j5 j6 j7 Some students may suggest trying the job with earliest start time. Ordering j1, j3, j6, j4, j7, j2, j5 Schedule j1, j7, j5

24
**Scheduling 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? j2 j1 j3 j4 j5 j6 j7 Now show that this doesn’t always give the optimal answer. Ordering j1, j3, j6, j4, j7, j2, j5 Schedule j1

25
**Scheduling 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. Ordering Schedule

26
**Scheduling The Jobs What is our algorithm? Example Ordering Schedule**

Sort the jobs by increasing finish time. Schedule each job if there are no conflicts. Example j1 j2 j3 j4 j5 j6 j7 Now show an algorithm that does always find the optimal. Ordering j3, j6, j1, j7, j4, j2, j5 Schedule j3, j7, j5

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 Devil’s Advocate Assume our solution is not the best This means there is a better solution B Show 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.

28
**The 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 >= n Q. 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

29
**The 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.

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

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google