1
1
1
2
• Little activity
• How to get ready for next lecture?
3
3
Learning Outcomes
At the end of this course, a student is expected to:
• Describe fundamental concepts pertaining to
computing science
4
• Computing science
• Problem solving
• Algorithm
• Decomposition
4
What is this course all about?
• Course Title: “Introduction to Computing Science
and Programming 1”
Learn fundamental
concepts of
computing science
5
This slide is from our Lecture 1.
What is Computing Science?
• Lot’s of answers out there
• For example:
• On youtube:
http://www.youtube.com/watch?v=U0luqHYa0EI
• On wiki: http://en.wikipedia.org/wiki/Computer_science
Will look at
• In a nutshell: Computer/Computing science is
this step 1. Creating solutions to problems (solution expressed as an
today. algorithm)
2. Analysing these algorithms (does it solve the problem? is
it efficient? etc…)
3. Automating these algorithms, often using computers
Will look at the first question
when we talk about “testing” Will look at this
and the second question 6
step throughout
when we talk about algorithm the rest of software
analysis. the semester.
Areas of Computing Science
• On wiki:
http://en.wikipedia.org/wiki/Computer_science
7
Computer versus Computing
• Computer: a tool
• According to
http://wordnetweb.princeton.edu/perl/webwn?s=computation
• The terms “calculation”, ”computation” and
“computing” are synonymous and they signify:
• “The procedure of calculating; determining something by 8
mathematical or logical methods.”
• Definition of Computation: problem solving that involves
numbers or quantities.
What is Computing Science?
• Lot’s of answers out there
• For example:
• On youtube:
http://www.youtube.com/watch?v=U0luqHYa0EI
• On wiki: http://en.wikipedia.org/wiki/Computer_science
• In a nutshell: Computer/Computing science is
1. Creating solutions to problems (solution expressed as an
algorithm)
2. Analysing these algorithms (does it solve the problem? is
it efficient? etc…)
3. Automating these algorithms, often using computers
9
software
Algorithm – Example
• Problem:
• You have no more milk.
12
Example – Get myself to SFU
in the morning
• Here is a high-level (i.e., no details) algorithm that’s
solves this problem, expressed in English
• Wake up
• Wash ourselves
• Eat breakfast
• Take the bus
• Observations:
• The steps may appear ambiguous to the person that is
to perform them, s/he may require more details 13
Example – Get myself to SFU
in the morning
• We disambiguate or “detail” the steps of a high-
level algorithm by decomposing each of its steps
into more detailed steps
• One way to do this is by asking
-> “What do you mean …”
when considering a step
• Let’s try!
14
Example – Get myself to SFU
in the morning
• What do you mean “Wake up”?
• I mean:
• stop clock alarm
• get out of bed
• …
15
Example – Get myself to SFU
in the morning
• What do you mean “Wash ourselves”?
• I mean:
• Turn on water
• Get undressed
• Step into shower
• Wash
• Here, again “What do you mean “Wash”?
• I mean:
• Shampoo my hair
• Rinse my hair
• Apply conditioner
• Rinse my hair some more
• Soap up my body
• Rinse my body
• …
• Step out of shower 16
• Dry myself
• …
Example – Get ready to go to
SFU in the morning
• See if you can continue this process of getting more
details by asking “What do you mean …” with the
rest of the steps of the high-level algorithm
• In other words, see if you can continue creating the
low-level (detailed) algorithm of our solution
17
Example – Get ready to go to
SFU in the morning
• Eat breakfast
•
•
•
•
•
•
•
18
Example – Get ready to go to
SFU in the morning
• Take the bus
•
•
•
•
•
•
•
19
Algorithm – observations?
21
Algorithm - Definition
• A finite sequenced set of unambiguous steps
• This set of steps executes in a finite amount of
time i.e. it should finish at some point, and when
it does, it produces a result
• This result solves the initial problem
• The algorithm also describes
• The input it is expecting, if any
• The output it is producing
22
More about algorithm
• https://www.khanacademy.org/computing/compu
ter-science/algorithms/intro-to-algorithms/v/what-
are-algorithms
23
How do we express an
algorithm?
1. Use a natural language like English
• Example:
• Problem/task: Figure out your course final grade
• Take all the grades you obtained in course activities (e.g.,
assignments, exams, etc…)
• Compute each grade as a % of final grade
• Add them up for a total of 100%
24
How do we express an
algorithm?
2. Use a mix of natural language and computer
language -> pseudocode
• Example:
• Problem/task: Figure out your course final grade
• Read each grade until EOF
• finalGrade = 0
• For each grade
• Set percentOfFinalGrade to this grade’s % of the final grade
• Set gradedOutOf to this grade’s max
• Compute newGrade: (grade * percentOfFinalGrade ) / gradedOutOf
• Keep a running total: finalGrade = finalGrade + newGrade
• Print finalGrade
• Else
• Print “Do not have all grades!”
25
How do we express
an algorithm?
3. Use a
flowchart
26
How do we express
an algorithm?
4.
http://www.ikea.com/ms/en_US/customer_service/as
sembly_instructions.html
27
Why do we need algorithms?
28