Introduction to Algorithm

Algorithm

Algorithm is a set of a step-by-step clear instructions to solve a problem. We can solve real life problems by using algorithm. For example, we can use algorithm to calculate the average score of five students. We should input those five students’ score, and then write the correct formula to calculate their average. Finally, we instruct the computer to output the average score.

Properties of Algorithm

Algorithm has five basic properties. Finiteness means that the operation of a set of instruction should be finite. It should not last forever. Definiteness means that all the instruction you offered should be well-defined, rigorous, and unambiguous. Input and Output refer to the indispensable procedure of programming which is input→process→output. Effectiveness regard of a characteristic of algorithm which is simple.

LightBot

Are you excited to “write” your own algorithm?  Go to play lightbot.com/hocflash.html. The following screenshots are the answers and explanation of some levels. Do look at them before trying by yourself.💪💪💪

Basic

Basics 1.pngBasic 1 ("LightBot")
Basics 2.png
Basic 2 ("LightBot")

Procedure

Procedures 1.png
Procedure 1 ("LightBot")

P1 stands for procedure 1. P1 command tells the robot to run the commands in PROC1. Whenever P1 command appears in Main, the robot will go through the commands in PROC1. It will more efficient to do so since you do need to write the a set of same commands again and again.

Procedures 4.pngProcedure 4 ("LightBot")

P1 and P2 represent two sets of repeating commands respectively. P2 is used in P1 and P1 is used in Main. By having two PROC, we can see that there are only three commands in Main which is very simple and efficient.

Loop

Loops 1.png
Loop 1 ("LightBot")

We we use P1 inside P1, the robot will run P1 over and over. That is how loop works in programming. We can see that there is only 1 procedure command in Main and the whole algorithm is more simple than those previous ones.

Loops 3.png
Loop 3 ("LightBot")


Personal Reflection: I think the LightBot games are very useful for understanding what algorithm and programming really are since these games visualized how basic algorithm, procedures, and loops work in programming.


 

Works Cited

“Lightbot”. Lightbot.com. N.p., 2016. Web. 17 Nov. 2016.

 

 

留下评论