Discrete Mathematics for Computer Scientists Anna Bretscher and Richard Pancer SY110Bretscher...
-
Upload
tyson-lobley -
Category
Documents
-
view
230 -
download
7
Transcript of Discrete Mathematics for Computer Scientists Anna Bretscher and Richard Pancer SY110Bretscher...
Discrete Mathematics for Computer Scientists
Anna Bretscher and Richard Pancer
SY110 Bretscher Fridays 10:10-12pm
SY110 Pancer 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
EvaluationTerm Test
– Week 7 or 8 worth 20%
Final Exam– Worth 40%
ResourcesCourse Slides
Posted each week.
Print them and bring to class.
Website
http://www.utsc.utoronto.ca/bretscher/a67/f13
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 MathematicsWho 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 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
Where Does Mathematics Appear in Computer Science?
Databases Set theory, logic
Artificial Intelligence Set theory, logic
Programming Languages
Set theory, logic
Formal Methods Set 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 SchedulingProblem
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
10
5
16 3
16
Some Examples
Time
25
10
19 3
17
Finding an AlgorithmQ. 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.
* Merrian-Webster
Time
10
5
16 3
18
Potential Algorithms
Largest weight first.
Other ideas?
Time
10
25
16 3
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
Q. Does this work?
A. Now Option 2 is Pick 16. Pick 11. Total = 27.
11
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: http://www.cs.princeton.edu/~wayne/kleinberg-tardos/06dynamic-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
NotationJ: 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 JobsWhat is our algorithm?
Examplej1 j2
j3 j4 j5
j6 j7
ChallengeFirst person to come up with a correct algorithm wins chocolate.
23
Scheduling The JobsWhat is our algorithm?
Sort the jobs by increasing start time. Schedule each job if there are no conflicts.
Examplej1 j2
j3 j4 j5
j6 j7
Ordering j1, j3, j6, j4, j7, j2, j5
Schedulej1, j7, j5
24
Scheduling The JobsWhat is our algorithm?
Sort the jobs by increasing start time. Schedule each job if there are no conflicts.
j1
j2
j3 j4 j5
j6 j7Ordering
j1, j3, j6, j4, j7, j2, j5
Schedulej1
Does this algorithm always find the best solution?
25
Scheduling The JobsOther ideas?
Ordering
Schedule
Does this algorithm always find the best solution?
26
Scheduling The JobsWhat is our algorithm?
Sort the jobs by increasing finish time. Schedule each job if there are no conflicts.
Examplej1 j2
j3 j4 j5
j6 j7
Ordering j3, j6, j1, j7, j4, j2, j5
Schedulej3, 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.
28
The ProofLet 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 ProofS = (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).