IB/Group 4/Computer Science/Computational Thinking, Problem-Solving, and Programming

Computer science is sometimes defined as the study of algorithms and their efficient implementation in a computer. The focus now is their role in problem solving, strategies for developing the, techniques for following and testing them. Because algorithms operate on data, we examine ways to structure data so that it can be more efficiently processed.

Thinking procedurally
Generally speaking, all problems begin with an idea. Finding the connection between this information and the solution lies at the heart of problem solving. To do this, the following strategies can be utilised.

Ask questions

When given a problem or task verbally, one typically asks questions until what is needed is known fully and clear. Generally, when, why, and where are asked until the task is completely specified. If the instructions are written, one might put question marks in the margin; underline a word, a group of words, or a sentence; or in some other way indicate the parts of the task that are not clear. Perhaps the questions might be answered in a later paragraph, or one might have to discuss them with the person giving the task. If the task is one that it self-set, this sort of questioning might not be verbal, but instead takes place on the subconscious level.


 * In this case, some typical questions that one should consider are:
 * What should I know about the problem?
 * What does the solution look like?
 * What sort of special cases exist?
 * How will I recognise that I have found the solution?

Look for Familiar Things
Don't reinvent the wheel. Exploit the similarities between previous problems solved. This is a form of pattern recognition.

Testing the Algorithm
We constantly break up a large problem into smaller units that we can handle. The task of cleaning the house or apartment may seem overwhelming. The task composed of cleaning the living room, the dining room, the kitchen, the bedrooms, and the bathroom seems more manageable. This principle is especially relevant to computing.

Do not reinvent the wheel. If a solution exists, use it. If you have solved the same or a similar problem before, just repeat the successful solution. We usually do not consciously think, "I have seen this before, and I know what to do" - we just do it. Humans are good at recognising similar situations. We do not have to learn how to go to the store and buy milk, then to buy eggs, then to buy candy. We know that going to the store is always the same and only what we buy is different.

Recognising familiar situations is particularly useful in computing. In computing, you see certain problems again and again in different guises. A good programmer sees a task, or perhaps part of a task (a subtask), that has been solved before and plugs in the solution. For example, finding daily high and low temperatures in a list of temperatures is exactly the same problem as finding the highest and lowest grades in a list of test scores. You want to the largest and smallest values in a set of numbers.

Thinking concurrently
Concurrent processing allows for faster computation, as multiple tasks are run simultaneously. However, concurrent processing is a lot more difficult to program.

Sequential search
There are numerous algorithms that exist in the realm of computer science, however, sorting and searching are two of the most important types.

Sequential, or linear, search is the simplest search algorithm; it is a special case of brute-force search. Its worst case cost is proportional to the number of elements in the list; and so is its expected cost, if all list elements are equally likely to be searched for. Therefore, if the list has more than a few elements, other methods (such as binary search or hashing) will be faster, but they also impose additional requirements.

Binary Search

This relies upon the linear array being sorted into order. Assume we want to find X. Note the 'middle' is always the larger element when you have an even set.
 * 1) Start at the middle element.
 * 2) Is X greater than or equal to that element?
 * 3) If yes, remove all lower than that from the population.
 * 4) Move to the middle of the new population and repeat.

Bubble Sort

Assuming we are sorting a list of numbers from lowest to highest.
 * 1) Starting from the left, compare that number X to the one on its right Y.
 * 2) Ix X>Y then swap X and Y around.
 * 3) Repeat through the entire list.
 * 4) Repeat whole process until nothing needs to switch on a full pass through.

Selection Sort

The simplest way to sort from low to high.
 * 1) Go through entire population and find the lowest.
 * 2) Shift the lowest to the farthest left.
 * 3) Ignore the sorted element(s), go through the remainder of the population in the same manner.