Year 1 CS

# CS Blog Post – Pseudocode

In this week, we began our learning about programing. Generally, we tried to solve simple arithmetic and logical problems by writing pseudocode. It’s much brief than compelling language as we needn’t to load and store data repeatedly. But it’s still very basic and direct, lack of many complex method compared to high-level language. In real life application, pseudocode is just like an outline for an article, make the programmer more clear about each part and explain the function in simple words.

Decision-Making process

Decision-Making process is a model that used to solve a problem in computing thinking. It’s useful skill to program efficiently. It can be classified into 4 stages – identification, development, selection and implementation. During the identification stage, we need to identify, understand and formulate the problem. It means we need to convert the problem in nature language into arithmetic version -identify the variable, original value, and expected value. Then, in the development stage, we come up with different methods that can input the original value and output expected value. Finally, in the implementation stage, we will choose the most efficient method.

Properties of Algorithm

In definition, algorithm is a set of step-by-step clear instructions to solve a problem in a reasonable amount of time for all general cases. A computer carries many detailed algorithm in order to satisfy diverse functions within in computer. ‘All general cases’ means that whatever the value it’s include exception error, the program using the algorithm can output the correct value (or error notification). So many programs testify the whole program or each part by inputing different values.

There are several basic properties of good algorithm. The first one is finiteness. A algorithm must have a number of finite instructions to solve the problem. The next is definiteness. A algorithm must have very clear and specific instructions to tell the computer what to do. Then, an algorithm need to have initial quantities that input to the program and quantities of output which relate to the input. Finally, effectiveness is also important as the time of process must be finite.

Expressions for Algorithm

There are different ways to describe the same algorithm. In our learning, there are generally four ways to represent it – natural language, flow chart, pseudocode and programming language. Natural language is using human language that we speak like English, Chinese and so on to describe the algorithm in complete sentences. Usually the description is quite verbose and ambiguous to express the method definitely. The flow chart is a kind of formalized graphic representation to show each step(with its attribution in different shapes) and the sequence. Then, pseudocode is an artificial language that combine nature language and program language together, more brief and efficient than natural language description. Finally, programming language is an artificial language that can directly communicate with the computer and create programs as the computer can convert it into assembly language and finally into machine code.

Pseudocode approved notations and best practices

There are several notations for pseudocode in order to become readable for others. Some of them are just as same as the function in programming language but more simple.

Input A – the user inputs some data (any type) into a variable called A.

Output – the program output the data of a variable called A.

While (expression) – end while – a loop that if the expression is true, the program will execute the statement between while and end while repeatedly. For do – while(expression), it will check the expression to know if continue the next time after statements between do and while have been executed.

For – a counting loop, there is a initial variable (usually 0 or 1) in the for loop, then each time the variable will + 1 and there is an expression used to check if the it reach the limitation. So that programer can regulate the time for the loop.

If (expression) – else if(expression) – else – the program will check whether the expression is true after if, if true, do the statement behind and end. If not, check the expression in else if in sequence. If all statements are false, the program will follow the statement after else.

Pseudocode examples/exercises

Rewrite:

Example 1:

Example 2:

Example 3:

Example 4:

Example 5:

Example 6:

Example 7:

###### end if

Centrally Controlled Systems, Distributed Systems, Autonomous Agent (for HL)

For centrally controlled systems, it a dedicated computer system that can control all parts of the computer and do the calculation, makes sure every components function well. All computing done at a central location by terminals. The computer itself may control all the peripherals directly or via terminal. The advantage for this system is lower operational costs, greater security and less administrative overhead and backup complexity. But Clients need to be able to connect efficiently and effectively to it.

For distributed system, it is a system that components located on networks computer and work together through passing messages, each component will take its own calculation and interact with the whole system. Even without the connection to the central system the function, the individual part can do its own job. They are easy to expand, adding or changing new parts. However, they are usually costly and require for additional hardwares. Backup of the system requires more bandwidth or resources at each site leads to higher complexity for the whole system.

In definition, autonomous agent is an object with a intelligent program that enable it to make its own decision. Generally it have three properties – limited ability to perceive its environment, process the environment and calculate an action, result a force, and no global plan/leader. For vehicles, there are three stages to perform how it makes decision – action – selection, steering – force, and low motion.

Personal Experience

This week, we discussed properties and expressions of algorithm and show our understanding by writing pseudocode. For HL topic, we learned autonomous agent. During the class, we also watched a model with several control systems and sensors to have a review for previous HL topic content.

Compared to writing assembly language, I feel much better for writing pseudocode as I have practiced writing it and high-level language before. It’s just fine for me to come up with the idea about how to deal with the question, but I need to pay attention to the details to avoid careless mistakes.

In the future, the basic knowledge of pseudocode will help me write the real program and get a clear idea before using the high-level programing language. In IB exam, most questions need to be done by pseudocode, so I still have lots of pseudocode practices in next two years.

That’s all for this week, I feel better for this topic than previous class and I am much interested in it. I think I will be more active in the class next week.