An algorithm is a finite, precisely described sequence of steps to solve a problem or complete a task. An algorithm must terminate in a finite amount of time.
Abstraction is a problem-solving technique that involves removing specific details to simplify problems. There are six types of abstraction:
Procedural decomposition is where a problem is broken down into a number of sub-problems, with each sub-problem accomplishing a specific task. Each sub-problem may be further subdivided.
Composition abstraction is where procedures are combined to form compound procedures, by "plugging" outputs from some procedures into the inputs of others.
Automation is where models of real-world objects are used to solve problems. Automation involves:
IS: Computer science involves building clean abstract models (abstractions) describing messy, noisy real-world objects or phenomena. Computer scientists choose what to include or discard in a model, to use the minimum amount of detail necessary to model the problem in order to solve a given problem to the required degree of accuracy.
Computer science puts models into action to solve problems. This involves creating algorithms that use the data that has been modelled.
A set is an unordered collection of unique values. Sets can be constructed:
{2 * x for x in {1, 2, 3}} constructs {2, 4, 6}. This is a set comprehension over the set {1, 2, 3}.Some symbols are expected to be known:
Sets can be represented compactly, for example:
A subset (
Types of set include:
The Cartesian products of two sets, written
The four set operations are:
A regular expression is a way of describing a set, allowing particular types of languages to be described in a convenient shorthand notation. For example:
a (a|b)* generates {a, aa, ab, aaa, aab, aba, abb, ...}aa+ generates {aa, aaa, aaaa, ...}a (a|b)? generates {a, aa, ab}.The following metacharacters are expected to be known:
*: 0 or more repetitions+: 1 or more repetitions?: 0 or 1 repetitions (i.e. optional)|: alternation (i.e. 'or')(): grouping regular expressions.The precedence of the above metacharacters is (from highest to lowest):
() grouping* + ? characters| alternation.a|bc+ generates {a, bc, bcc, bccc, ...}Regular expressions and FSMs are equivalent ways of defining a regular language. A regular language is any language that can be represented by a regular expression, or any language that a FSM will accept.
A context-free language is a wider set of languages following context-free grammars, which are formed of production rules. Context-free languages can be represented using Backus-Naur Form (BNF):
<integer> ::= <digit> | <digit> <integer>
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<number> ::= <integer> | <integer> . <integer>
(this is a bad example)
BNF represents some languages that cannot be represented using regular expressions because it allows recursion.
Algorithms can be compared by expressing their complexity as a function relative to the size of the problem input. Algorithms can be more efficient time-wise, or space-wise.
IS: Efficiently implementing automated abstractions means designing data models and algorithms that run quickly while taking up minimal amounts of resources such as memory.
Mathematical functions are used to describe complexities:
The number of permutations of
Big-O notation is used to express time complexity. The following complexities are expected to be known:
Algorithmic complexity and hardware impose limits on what can be computed. Problems can be classified as being:
Some problems cannot be solved algorithmically. For example, the Halting problem is the unsolvable problem of determining, without executing the program, whether any program will eventually stop if given a particular input. This demonstrates that there are some problems that cannot be solved by a computer.
Turing machines are a model of computation. They can be viewed as a computer with a single fixed program, expressed by:
A Universal Turing machine is a Turing machine that could simulate any other Turing machine by reading a description of it from the input tape. Turing machines are important as they provide a general / formal model of computation, giving a definition of what is computable.