In this week’s class (which is really a long week), we focused on the term ‘Algorithm’ and dived deeper into this topic by introducing the properties, characteristics, expressions of algorithm.
- Computational thinking
There are four parts of computational thinking: decomposition, abstraction, pattern recognition and algorithm.
Decomposition is the process of breaking down a complex problem or task into smaller parts. Abstraction is about focusing on relevant information and ignoring unimportant details, which is doing one particular thing at a time. Pattern recognition is somehow like to conclude a similarity among problems. Algorithm, which I am going to talk about next, is about listing all the possible steps in order to accomplish the goal.
Take the lightbot game as an example, we decompose and abstract the tasks into different movements, or different sections. Later on, we needed to recognize a pattern so that we can follow this ‘loop’ later on. At last, we needed the algorithm to express out all the thinking that we just done and give instructions for the robots. This game enhanced my understanding on computational thinking, and kind of built up my understanding of solving a problem logically and in step-by-step order.

- Term ‘Algorithm’
The term ‘Algorithm’ refers to a set of well-defined instructions in sequence in order to solve the problem efficiently and effectively.
In class, we did two activities related to algorithm to further strengthen our understanding on this term. First one is that one student act as the robot, and the other act as the system which gives the instructions to the robot. The goal for the robot is to grab the object on the desk that is few meters away. However, the eyes of ‘robot’ will be covered and ‘robot’ has to approach the object by only listening to the oral instructions, for instance ‘go forward for 1 step’, or ‘turn left for 90 degrees’, etc. Another activity is to design the most efficient way of visiting different sites in a map without missing any of them.

- The characteristics of Algorithm
There are five important characteristics of an algorithm that should be considered while designing any algorithm for any problem.
- Finiteness
An algorithm should terminate infinite number of steps and each step must finish in finite amount of time. An algorithm that never terminates is useless since it’s impossible to know the difference between continued progress and being ‘stuck’.
2. Definiteness
This indicates that an algorithm must be explicit about how to work the computation. Definiteness comes by giving commands that state unambiguously what to do, in sequence. Some examples of the commands might be conditional and repeated sentences (loops), which requires the clear and precise directions on how to respond to different outcomes or when to stop the repetition.
3. Effectiveness
Effectiveness assures that the agent following the instructions is able to do without intervention. This is usually achieved by reducing the tasks and operations to the computer. The connection between definiteness and effectiveness is that definiteness ensures that the computer always know what to perform next; while effectiveness guarantees that the computer can accomplish the command that the user gives.
4. Input
The input is the data that will be transformed by algorithm to create the output. An algorithm must have zero or more but must be finite number of inputs. Usually when establishing an algorithm, users have to concern about the types of data, the structure of it and the actually number of the variable.
5. Output
Output is the result of the computation, or algorithm. An algorithm must have at least one desirable outcome (output).
- Designing an algorithm and understanding the problem
It does take some process to design an algorithm. Firstly, it’s important to have a first glance of it, which is to look at it from a broad view. Before we actually start to establish the algorithm, we have to settle down the problem that we are going to solve through this algorithm. Secondly, we should be clear about the instructions in each step and be aware of the potential obstacles that we will face.
Besides, before the algorithm can be designed, it’s essential to understand the problem thoroughly. For instance, what is the desired input and output of the algorithm; what decisions have to be made in the problem and are there any repeated section of the algorithm?
- Expression for algorithm
After the algorithm is designed, the next thing comes up is how to express the algorithm in readable format. It’s usually displayed in four types, natural language, flowchart, pseudocode and programming language.
Natural language can also be known as a human language, in this case, is in English. It contains three steps: fetch an instruction, decode the instruction and then execute it. For instance, when you want to display a sentence ‘CS is the best subject in IB!!’ for three times, the format of natural language is simply “display the message ‘CS is the best subject in IB!!’ three times”.
Flowchart is a formalized graphic representation to represents a workflow or process. The flowchart shows the steps as boxes of various kinds, and they’re ordered by connecting the boxes with arrows.

Pseudocode is the genetic artificial language. I think it somehow performs as the combination of natural language and programming language because it’s both understandable for human beings and it’s similar to what an actual program looks like. The pseudocode is also highly related to the flowchart, and like a more visual representation of it.
Programming language is the artificial language to communicate with the computer system. Some common languages are C, Python, Java… And each of these programming languages are specified in different fields, for instance database, web data, or artificial intelligence.

- Algorithm Magic
Our group was assigned with a presentation about a ‘magic’ show, which is called ‘red black mind meld’. At the beginning of this trick, the magician and the volunteer will both have equal amounts of cards, which is 26. Later on, magician picks a random number (1-5) and colour (red or black), places that many cards in to a red or black pile as appropriate, then volunteer randomly places the same number of unseen cards in a pile in front of that pile. And finally, when we were counting the red cards in the pile in front of the red pile and black cards in the pile in front of the back pile, we found the number was same. In fact, this conclusion can be explained by using abstraction, logical thinking and algorithm. (We didn’t use zoho doc -_-)
- The secret rules of modern living: Algorithms
—PageRank Algorithm—
This algorithm can be visually shown in a football match. The more passes a player receives, the more important he/she is. So that, the passes from a popular player, who receives a lot of passes, weighs more than other players. Google is using this type of algorithm in their searching engine. PageRank gives each page a rating of its importance, which is recursively defined measure whereby a page becomes important if important pages link to it.

—Bubble sort algorithm—
This algorithm functions in a way that system sort things firstly in pairs in sequence, for instance from left to right. If the order of two numbers are wrong, then the system will swap them over to the right over. By repeating this process again and again, everything will be sorted in right order. But this type of sorting algorithm takes a longer time to accomplish compared to others. When I’m writing programs, algorithms are always a huge obstacle for me and this is the thing that I really have to improve on.

- Conclusion
We learned a lot in this ‘long’ week, for instance computational thinking and characteristics/expressions of algorithms, as well as various kinds of activities and presentations to strengthen our understanding. As soon as I got in touch with flowchart and pseudocode, I found out that those two expressions of algorithms are essential for programming because it would help me to make a clear logic sequence and know what I should do next in my programs. I think will implement those tools when I’m writing a code next time.

