2. Algorithms¶
Since problem solving is a central part of computer science, the solutions that you create through the problem solving process are also important. In computer science, we refer to these solutions as algorithms. An algorithm is a step by step list of instructions that if followed exactly will solve the problem under consideration.
One of the characteristics of algorithms is that they do not require any intelligence to carry out (i.e., they can be done by computers). They are mechanical processes in which each step follows from the last according to a simple set of rules. On the other hand, determining the steps of each algorithm — what exactly needs to be done, and in what order, to solve the problem at hand — requires a great deal of thought and experimentation. So while the execution of the algorithm may be boring and require no intelligence, it is the process of designing algorithms that is interesting, intellectually challenging, and a central part of what we call programming.
Some of the things that people do naturally, without difficulty or conscious thought, are the hardest to express algorithmically. Understanding natural language is a good example. We all do it, but so far no one has been able to explain how we do it, at least not in the form of a step-by-step mechanical algorithm.
Our goal in computer science is to take a problem and develop an algorithm that can serve as a general solution. Once we have such a solution, we can use our computer to automate the execution. As noted above, programming is a skill that allows a computer scientist to take an algorithm and represent it in a program that can be followed by a computer. These programs are written in programming languages.
Check your understanding
-
What is the most important skill for a computer scientist?
- To think like a computer.
- Computers do not think, they only do what we humans tell them to do via programs.
- To be able to write code really well.
- While it is necessary for most computer scientists to know how to write code, it is not the most important skill.
- To be able to solve problems.
- Computer scientists are all about solving problems. We use computers to automate solutions to problems and to do things faster and more accurately than we can do manually.
- To be really good at math.
- Computer science and math are similar in many ways and it helps to have a strong mathematical foundation, but you do not have to be good at math to be a good computer scientist.
-
An algorithm is:
- A solution to a problem that can be solved by a computer.
- While it is true that algorithms often do solve problems, this is not the best answer. An algorithm is more than just the solution to the problem for a computer. An algorithm can be used to solve all sorts of problems, including those that have nothing to do with computers.
- A step by step list of instructions that if followed exactly will solve the problem under consideration.
- Algorithms are like recipes: they must be followed exactly, they must be clear and unambiguous, and they must end.
- A series of instructions implemented in a programming language.
- Programming languages are used to express algorithms, but an algorithm does not have to be expressed in terms of a programming language.
- A special kind of notation used by computer scientists.
- Computer scientists sometimes use a special notation to illustrate or document an algorithm, but this is not the definition of an algorithm.