CPSC 121: Models of Computation Unit 0 Introduction Based on - - PowerPoint PPT Presentation
CPSC 121: Models of Computation Unit 0 Introduction Based on - - PowerPoint PPT Presentation
CPSC 121: Models of Computation Unit 0 Introduction Based on slides by Patrice Belleville and Steve Wolfman Introductions Sections 101 and 102 : Instructor: George Tsiknis Office: ICCS 307 Email: tsiknis@cs.ubc.ca Office Hours: TBA on
Introductions
Sections 101 and 102:
Instructor: George Tsiknis Office: ICCS 307 Email: tsiknis@cs.ubc.ca Office Hours: TBA on course web site
Sections 103:
Instructor: Ryan Vogt Office: ICCS 247 Email: vogtr@cs.ubc.ca Office Hours: TBA on course web site
Course Coordinator:
Trey Scheifelbein Email: cpsc121-admin@cs.ubc.ca)
TAs : See course site.
Unit 0 - Introduction 2
Today's Learning Goals
By the end of this unit, you should be able to:
- Give an example of how we can apply formal
reasoning to a simple, real-world task.
- Give an example of how a computational solution to
this simple task might go wrong.
- Describe the four “big questions” which we will
address in CPSC 121.
Unit 0 - Introduction 3
Activity
Find an algorithm to order students by birthday.
Unit 0 - Introduction 4
Jan 1st Feb 24th Jul 24th Jul 31st Sept 18th
Problem
How many swaps did you need to make?
Unit 0 - Introduction 5
Question
What is the maximum number of swaps we may make to order 4 people by their birthday?
- a. 3
- b. 4
- c. 6
- d. 12
- e. None of these
Unit 0 - Introduction 6
How many swaps?
For 1 person? For 2 people? For 3 people? For 4 people? For 5 people? … For n people?
Unit 0 - Introduction 7
Computing Swaps with DrRacket
Computing n(n-1)/2 using DrRacket:
Unit 0 - Introduction 8
Computing Swaps in Java
Computing n(n-1)/2 using Java:
Unit 0 - Introduction 9
import java.io.*; public class Compute { public static void main(String[] args) { int n = Integer.parseInt(args[0]); System.out.println(n * (n-1) / 2); } } poirot> java Compute 5 10 poirot> java Compute 1000 499500 poirot> java Compute 1000000
- 364189984
Questions About this Exercise:
How can we prove that n(n-1)/2 is the largest number
- f swaps needed for n birthdays?
- Can use the method of Mathematical Induction
Why did our Java implementation print a negative
value, but not the Racket implementation?
- Use different Number Representation
Unit 0 - Introduction 10
CPSC 121: The BIG questions:
- 1. How can we convince ourselves that an algorithm
does what it's supposed to do?
- 2. How do we determine whether or not one algorithm
is better than another one?
- 3. How does the computer (e.g. Dr. Racket) decide if
the characters of your program represent a name, a number, or something else? How does it figure
- ut if you have mismatched " " or ( )?
- 4. How can we build a computer that is able to
execute a user-defined program?
Unit 0 - Introduction 11
? ?
Our Working Computer
A working computer you will learn about in the labs:
Unit 0 - Introduction 12
Course Learning Outcomes
After you complete the course, you will be able to:
- model important problems so that it is easier to discuss,
reason about, solve, and test them.
- learn new modeling formalisms more easily.
- communicate clearly and unambiguously with other CS
experts on complex topics.
- characterize algorithms (CS problem solutions), by proving
their correctness or efficiency.
- critically read proofs: justifying why each step is correct and
judging what the proof means.
- explain how computers work.
Unit 0 - Introduction 13
Course Sites
Explore the CPSC 121 website:
http://www.ugrad.cs.ubc.ca/~cs121/2017W1/
- You are required to be familiar with the course website.
Read carefully the Course Info section on the course
web site.
Check the Connect site for the course for Pre-class
Quizzes & Marks:
- http://www.connect.ubc.ca
Check the Piazza site for the course discussion board:
- https://piazza.com/ubc.ca/winterterm12017/cpsc121
to signup
- https://piazza.com/ubc.ca/winterterm12017/cpsc121/home
after that. Check announcements very often
Unit 0 - Introduction 14
Course Activities
Here are the parts of this course.
- Lecture (required): cover theoretical material
- Clicker questions: check understanding of lecture concepts
- Labs (required): work hands-on with model computer
- Online quizzes (required): test understanding of readings
- Tutorials (optional): highly recommended practice problems
- Midterms (2)
- Final Exam
Unit 0 - Introduction 15
Grading
Your final grade will be computed as following:
- Assignments (5)
14%
- Labs (9)
14%
- Pre-class Quizzes (~10)
5%
- In class participation
(Clicker Questions) 3%
- Midterm #1
12%
- Midterm #2
12%
- Final Exam
40%
To pass the course, you must obtain at least 50% on the
final exam, and at least 50% on your combined lab and assignment marks.
Unit 0 - Introduction 16
Labs and Tutorials
Labs
- Start on Monday September 11th.
- Usually have a pre-lab and in-lab work
- Pre-lab work must be done before you get to the lab.
- In-lab work must be completed during the lab time, so the TAs will be
able to mark it.
- You must attend the lab you are registered for.
Tutorials
- Start on Monday September 11th.
- You will work in small groups on problems suggested by the TA.
- Try to attend the tutorial you are registered for.
Unit 0 - Introduction 17
Assignments, Quizzes and Exams
Assignments
- Problems that exercise the material discussed in the lectures.
- We encourage you to do them in groups of two.
Pre-Class Reading and Quizzes
- To facilitate your learning we assign reading from the text
followed by a related quiz before certain lectures.
- Usually one quiz every week, due at 7:00pm before the
lecture day.
- Each quiz has two parts: part A and part B. MAKE SURE YOU
DO BOTH.
There will be 2 midterms:
- Friday October 13th, 2017, from 17:00 to 18:00, and
- Wednesday November 15th, 2017, from 18:00 to 19:00.
The final exam will be scheduled by UBC in December.
Unit 0 - Introduction 18
Lab and Assignment Schedule
19 Unit 0 - Introduction
Sunday Monday Tuesday Wednesday Thurday Friday Sept 3rd First class Sept 10th Lab 1 Lab 1 Lab 1 Lab 1 Lab 1 Sept 17th Lab 2 Lab 2 Lab 2 Lab 2 Lab 2 Sept 24th Lab 3 Assign 1 due Lab 3 Lab 3 Lab 3 Lab 3 Oct 1st Lab 4 Lab 4 Lab 4 Lab 4 Lab 4 Oct 8th Holiday Assign 2 due Midterm 1
Lab and Assignment Schedule (cont')
20 Unit 0 - Introduction
Sunday Monday Tuesday Wednesday Thurday Friday Oct 15th Lab 5 Lab 5 Lab 5 Lab 5 Lab 5 Oct 22nd Lab 6 Lab 6 Lab 6 Lab 6 Lab 6 Assing 3 due Oct 29th Lab 7 Lab 7 Lab 7 Lab 7 Lab 7 Nov 5th Lab 8 Lab 8 Lab 8 Lab 8 Lab 8 Assign 4 due Nov 12th Holiday
Midterm 2
Nov 19th Lab 9 Lab 9 Lab 9 Lab 9 Lab 9 Nov 26th Assgn 5 due
Tips for Success (University and 121)
Success in lecture?
- Taking notes, beyond just printing slides
- I recommend pen / pencil for CPSC 121
Success overall?
- Get a copy of (one of) the textbooks right away
- Staple your assignments before turning them in
Who do I contact?
- Lecture questions: Piazza, instructor office hours, TA office
hours (“Demco” or “DLC” hours)
- Lab questions: your lab TA
- HR matters (registration, etc.): course coordinator
- Regrade requests: course coordinator
- Private matters: instructor via email
Unit 0 - Introduction 21
First Quiz
The first online quiz is due: Sunday, Sept 10, at
7:00pm.
- You should complete Quiz 1 before you start Lab 1
Sections to read for the quiz:
- Epp, 4th edition: 2.1 and 2.4.
- Epp, 3rd edition: 1.1 and 1.4
- Rosen, 7th edition: 1.1 up to the top of page 6, and 12.3.
- Rosen, 6th edition: 1.1 up to the top of page 6, and 11.3.
Unit 0 - Introduction 22
Second Quiz
Second online quiz is due on
Wednesday, Sept 13, 7:00pm.
Assigned reading for the quiz:
- Epp, 4th edition: 2.2
- Epp, 3rd edition: 1.2
- Rosen, 6th or 7th edition: 1.1 from page 6 onwards.
Unit 0 - Introduction 23