Week 7 Blog

Algorithm is a set of step-by-step clear instructions to solve a problem. It can be a real-life problem or a computing problem, but computers cannot directly understand this sort of code. For example, when we want to clean a classroom but the room was extremely messy and hard to clean, we can use algorithm to separate each steps and do the cleaning more logically and throughly. 

Decision Making Process

  • Identification: identify, understand and formulate the problem
  • Development: explore various alternatives
  • Selection: choose the best alternative
  • Implementation: Execute the selected alternative

Properties of Algorithm

  • Finiteness: a reasonable number of steps
  • Definiteness: steps are precisely defined; actions must be rigorously and unambiguously specified
  • Input: initial quantities
  • Output: quantities with specified relation to the inputs
  • Effectiveness: algorithm has to be sufficiently done in a finite amount of time

Expressions of Algorithm

  • Natural Language: simple english
  • Flow Chart: formalized graphic representation
  • Pseudocode: generic artificial language
  • Programming Language: language that computers can understand 

Pseudocode Notations and Conventions

  • INPUT: indicates a input
  • OUTPUT: indicates an output
  • LOOP WHILE: loop under a certain condition
  • LOOP FOR: loop for certain times
  • REPEAT – UNTIL: look until a certain condition is achieved
  • IF – THEN – ELSE: a decision (selection) after a choice is made

Trace Table

Trace table is a technique to test the validity of an algorithm. There are several steps to create a trace table. 

  1. Write down all the variables, conditions and output in the first row
  2. Create a column for each step and number them from 0 to n
  3. Start filling in initial values in the second row
  4. Input all loop values vertically in rows after that
  5. Follow each statement in the code and fill the respective values of the variables or judge whether each condition are achieved or not
  6. Write down the final output 

Class Activities

WechatIMG531
Front of the paper
WechatIMG530
Back of the paper
WechatIMG532
Ship finding activity

We did several examples on the slides for activity. During the ship-finding exercise, we introduced the concept called array. It is a set of number with assigned addresses. Through this activity, we learnt the idea of how to find an item quickly.

The algorithm in the first round was simple: asking the opponent one by one, from the first place to the last place, until one side find the answer. However, finding item through this way is rather time consuming. The second round, each of us was assigned with a similar sheet, so I can use my sheet to estimate the number in my opponent’s hand. This way, the finding process is much more easier and faster.

Centrally System and Distributed System

In the week before last week, we learnt two computing system called centrally systems and distributed system. 

Centrally system refers to a system with a central computer that do all the necessary calculations, but there are multiple terminals that can separately control those computers. It usually has lower operational cost and it is more secured, but cause there are just one data location. It can be imagined as a room with doors. If there is only one door, one guard is needed to keep the security. However, if there is more than one door, more people and cost would be needed. Also, it is easier to give administration privilege and to backup because of the central data location. However, if the central computer breaks down, the whole system will stop working because of the central data location as well.

Distributed system, on the other hand, refers to a system with components located on networked computers, while each computer in the system contribute to one part of essential calculations. It is usually built with heterogeneous technology. If one of the computers break down, no catastrophic failure would be caused because there are still other computers working normally in the system. That is to say, it usually has a strong self-sustaining ability. It is expandable, which means more components can be added in the system. However, it is usually costly, requires additional hardware, and hard to keep the system safe.

Distributed system has several properties:

  • Scalability: possibility of adding new hosts
  • Extensibility/openness: can be easily extended and modified
  • Heterogeneity: supports various hardware and software platforms; make of varies technologies
  • Resource sharing: computers in the network share hardware, software and data
  • Fault tolerance: the system can still function when faults occur

Conclusion

Things we learnt this week was super practical in real life. It helps us the build logical thinking process when solving a problem. I’m looking forward to the classes next week 🙂