01 Lab Week1
01 Lab Week1
01 Lab Week1
Computational Intelligence
COMP8802
Laboratory Week 1
Schedule
Week Week Material Book Week Week Material Book
Beginning Beginning
1 February 27 An Introduction to Computer Level 1 Mid-Sem Break
Science - Algorithms & History
Mid-Sem Break
7 April 24 Computational Models Level 4 & 5
2 March 6 Algorithms continued Level 1
3 No Lecture Monday Public Holiday
8 May 01 Artificial Intelligence / Ethics Level 5 & 6
4 March 20 The Building Blocks / Computer Level 2 9 May 08 Databases / Data Analysis
Organization
Level 5
• Lecture slides
• Lecture recording
• Contact information
• Contact times
• Announcements
• Assignments
• …
Canvas Orientation
• Live
Learning Objectives
• Understand the definition of computer science
• Sequential operations
• Carries out a single well-defined task
• Conditional operations
• Ask a question and the next operation is then selected on the basis of the
answer to that question
• Iterative operations
• Looping instructions that tell not to go on but go back and repeat the
execution of a previous block of instructions
Group Exercise
• Get a value for x from the user.
• Sequential operations
• Carries out a single well-defined task
Group Exercise
• Test to determine if x is positive. If not, tell the user that he
or she has made a mistake.
• Sequential operations
• Carries out a single well-defined task
• Conditional operations
• Ask a question and the next operation is then selected on the basis of the
answer to that question
• Iterative operations
• Looping instructions that tell not to go on but go back and repeat the
execution of a previous block of instructions
Group Exercise
• Test to determine if x is positive. If not, tell the user that he
or she has made a mistake.
• Conditional operations
• Ask a question and the next operation is then selected on the basis of the
answer to that question
Group Exercise
• Take the cube root of x.
• Sequential operations
• Carries out a single well-defined task
• Conditional operations
• Ask a question and the next operation is then selected on the basis of the
answer to that question
• Iterative operations
• Looping instructions that tell not to go on but go back and repeat the
execution of a previous block of instructions
Group Exercise
• Take the cube root of x.
• Sequential operations
• Carries out a single well-defined task
Group Exercise
• Do Steps 1.1, 1.2, and 1.3 x times.
• Sequential operations
• Carries out a single well-defined task
• Conditional operations
• Ask a question and the next operation is then selected on the basis of the
answer to that question
• Iterative operations
• Looping instructions that tell not to go on but go back and repeat the
execution of a previous block of instructions
Group Exercise
• Do Steps 1.1, 1.2, and 1.3 x times.
• Iterative operations
• Looping instructions that tell not to go on but go back and repeat the
execution of a previous block of instructions
Group Exercise - Multiplication
• One way to do multiplication is by repeated addition.
• For example, 47 × 25 can be evaluated as
47 + 47 + 47 + … + 47 (25 times).
Step 0. set c to 0
Step 1. set i to 0
Step 2. while (i < b) repeat instructions in steps 3-4
Step 3. add a to c
Step 4. add 1 to I
Step 5. print out c
Step 6. stop
Multiplication by Addition
Step 0. set c to 0
• Sequential operations
• Carries out a single well-defined task
• Conditional operations
• Ask a question and the next operation is then selected on the basis of the
answer to that question
• Iterative operations
• Looping instructions that tell not to go on but go back and repeat the
execution of a previous block of instructions
Multiplication by Addition
Step 0. set c to 0
• Sequential operations
• Carries out a single well-defined task
Multiplication by Addition
Step 1. set i to 0
• Sequential operations
• Carries out a single well-defined task
• Conditional operations
• Ask a question and the next operation is then selected on the basis of the
answer to that question
• Iterative operations
• Looping instructions that tell not to go on but go back and repeat the
execution of a previous block of instructions
Multiplication by Addition
Step 1. set i to 0
• Sequential operations
• Carries out a single well-defined task
Multiplication by Addition
Step 2. while (i < b) repeat instructions in steps 3-4
• Sequential operations
• Carries out a single well-defined task
• Conditional operations
• Ask a question and the next operation is then selected on the basis of the
answer to that question
• Iterative operations
• Looping instructions that tell not to go on but go back and repeat the
execution of a previous block of instructions
Multiplication by Addition
Step 2. while (i < b) repeat instructions in steps 3-4
• Iterative operations
• Looping instructions that tell not to go on but go back and repeat the
execution of a previous block of instructions
Multiplication by Addition
Step 3. add a to c
• Sequential operations
• Carries out a single well-defined task
• Conditional operations
• Ask a question and the next operation is then selected on the basis of the
answer to that question
• Iterative operations
• Looping instructions that tell not to go on but go back and repeat the
execution of a previous block of instructions
Multiplication by Addition
Step 3. add a to c
• Sequential operations
• Carries out a single well-defined task
Multiplication by Addition
Step 4. add 1 to i
• Sequential operations
• Carries out a single well-defined task
• Conditional operations
• Ask a question and the next operation is then selected on the basis of the
answer to that question
• Iterative operations
• Looping instructions that tell not to go on but go back and repeat the
execution of a previous block of instructions
Multiplication by Addition
Step 4. add 1 to i
• Sequential operations
• Carries out a single well-defined task
Multiplication by Addition
Step 5. print out c
• Sequential operations
• Carries out a single well-defined task
• Conditional operations
• Ask a question and the next operation is then selected on the basis of the
answer to that question
• Iterative operations
• Looping instructions that tell not to go on but go back and repeat the
execution of a previous block of instructions
Multiplication by Addition
Step 5. print out c
• Sequential operations
• Carries out a single well-defined task
Multiplication by Addition
Step 6. stop
• Sequential operations
• Carries out a single well-defined task
• Conditional operations
• Ask a question and the next operation is then selected on the basis of the
answer to that question
• Iterative operations
• Looping instructions that tell not to go on but go back and repeat the
execution of a previous block of instructions
Multiplication by Addition
Step 6. stop
• Sequential operations
• Carries out a single well-defined task
Group Exercise - Multiplication
• One way to do multiplication is by repeated addition.
• For example, 47 × 25 can be evaluated as
47 + 47 + 47 + … + 47 (25 times).