Grade 10, Pre-IB Computer Science

#COMPUTER SCIENCE# WEEK 6

Welcome

This is the third week of October. During this week’s Computer Science class, we are still learning about algorithm. We did several projects to know how algorithm works. On the second class of this week, we saw few videos to know how to know several expressions of algorithm and how to solve problems.

Algorithm Properties: Finiteness  Definiteness  Input  Output  Effectiveness

In a algorithm, there must be finite number steps. Each step must be definitely precise. The actions need to be strict. There need to be an input before algorithm begins. Outputs are quantities related to inputs. All steps in algorithm must be sufficiently basic and they can be done in finite time.

Understanding a problem

There are several factors that we need to concern: What is the input? What will be the output? What will be the order of instructions ? What decisions should be made in order to solve the problems ? Are any part of the task repeated?(a loop can be created in the situation)

Activities

During the first class of this week, we did two activities to learn how to design a algorithm. The first activity was a student with his eyes covered with something that he could not see anything was listened to another student’s instructions to get to the appointed tile and he should avoid step on the tile that has a marker. By the activity, I learn that the instructor should say the instructions step by step. The instructions must be clear. For example, he should say how long the student should step froward instead of saying a big step or a small step. The algorithm should try to be simple as far as possible.

The second activity was to write how to boil an egg within the group. By this activity, I know that when designing a algorithm, we should not forget any steps. If we forget even a step, the result will change. We should be strict at every step in the algorithm.

Game

This week we did a interesting game on the computer. It is a game that we design the algorithm to make the little robot on the screen light all blue squares. It is really funny. By this small game, I know more about algorithm and how to design it. There are simple ways and difficult ways to reach the same aim.

Screen Shot 2017-10-22 at 10.11.54 PMScreen Shot 2017-10-22 at 9.12.52 PMScreen Shot 2017-10-22 at 8.50.37 PM

Algorithm

Algorithm is instructions of all problems. It is a general solution. There are both easy algorithms and difficult algorithms for a problem. For example, the problem is counting the number of people in a room.

 

Let N=0

For each person in room

Set N=N+1                But it is not efficient to count a person once a time.

Let N=0

For each pair of people in room

Set N=N+2                Buggy odd number people

Let N=0

For each pair of people in the room

Set N=N+2

If there is remains a person

Set N=N+1

So when we design a algorithm, we should consider all conditions in case of bugs.

Expressions for algorithm

Natural language(simple language description)                                                                                             Flow chart(formalized graphic representation, a type of diagram)     flowbreeze-order-flowchart

Pseudocode(an informal high leveled description)        

Programming language(formal language to specify a set of instructions)

Pseudocode

It is a planning tool that allow us to design the flow of a program prior to writing the code. It consists of a series of English-like statement that describe a task or algorithm. There are several common notation used in pseudocode.

A==9     A equal nine

A=9      Sign 9 to A

Input:  Read, obtain, get

Output: an output will shown on the screen

While: a loop

For: a counting loop

Repeat-Until: a loop that has conditions at the end of it

If-Then-Else: a decision when a choice is made

Screen Shot 2017-10-23 at 5.28.20 PM.png

Languages1.png

Pseudocode

Begin

Input a number

While the number is between 0 and 30

If it is between 0 and 20

If it is between 0 and 10

Output the word red

Else

Output the word blue

End if

Else

Output the word green

Else

There is no a correct color option

End if

Stop

Begin

Input a number <the number is between 1 and 100( include 1 and 100)>

If it can be divided by 5 and there is no remain

Print the number

Else

No print

End if

Stop

Leave a comment