An algorithm is a set of instructions that can be followed to perform a task, and always terminates
An algorithm could be expressed through a flow chart or pseudocode
Pseudocode allows for working through the logic of a program without worrying about syntax
We can hand-trace algorithms by taking them one line at a time and recording any changes in variables, as well as any outputs. This helps to work out what a program is doing.
Good pseudocode can make it easier to program in a high level language
It is important to account for all data a user might input
Valid data - data we expect the user to input
Invalid data - data we expect to generate an error (preferably caught or not accepted)
Borderline data - data at the boundaries of acceptable values. Important to test to make sure it works as intended
There may be other data we want to test for other reasons, for example checking compatibility with floats. Be prepared to come up with tests that are relevant to a given program
We can accept feedback from users to improve and refine a program
Abstraction is the process of hiding unnecessary detail.
Representational abstraction means representing a problem in a simplified way with unnecessary detail removed
Abstraction by generalisation means forming a hierarchical relationship by grouping common characteristics via 'is a kind of'
Information hiding means hiding non-essential details so that it is easy to focus on what matters
Procedural abstraction means abstracting any particular values in a problem to create a computation pattern or computational method; a procedure.
We can abstract procedural abstraction further to achieve functional abstraction, where we hide the method so that we only see the input and output
Data abstraction means specific details of how data is represented are hidden, in other words, how they are implemented in the code. This is the basis of abstract data types.
Problem abstraction (or reduction) means we remove details from a problem we want to solve until it is reduced to a problem that has already been solved - for example plotting out a journey on a map abstracts into Dijkstra's algorithm
Decomposition means breaking a problem down into smaller sub-problems until they are all individual tasks that are easier to solve
Composition means combining existing procedures into compound procedures - for example by using libraries
Composition can be seen in abstract data types, which are made up of smaller and simpler data types
Automation means using abstracted models of real world situations to solve problems
Computer science ultimately is about automating problems to simulate them and analyse them in a way we couldn't otherwise - whether this is modelling the growth of cancer cells or creating an interactive game for entertainment
To automate, we design algorithms, implement them through code, implement abstracted models via data structures, and then execute everything