OpenLLM-France/wikimedia huggingface dataset:
# A-level Computing 2009/AQA/Problem Solving, Programming, Operating Systems, Databases and Networking/Problem Solving/BigO notation
## Timing

You can work out the time that an algorithm takes to run by timing it:
However, this isn't always suitable. What happens if you run some code on a 33 MHz processor, and some code on a 3.4 GHz processor. Timing a function tells you a lot about the speed of a computer and very little about the speed of an algorithm.

## Refining algorithms

optimised version
| Notation | Name | Example |
| $O(1)\,$ | constant | Determining if a number is even or odd; using a constant-size lookup table |
| $O(\log n)\,$ | logarithmic | Finding an item in a sorted array with a binary search or a balanced search tree as well as all operations in a Binomial heap. |
| $O(n)\,$ | linear | Finding an item in an unsorted list or a malformed tree (worst case) or in an unsorted array; Adding two n-bit integers by ripple carry. |
| $O(n\log n)=O(\log n!)\,$ | linearithmic, loglinear, or quasilinear | Performing a Fast Fourier transform; heapsort, quicksort (best and average case), or merge sort |
| $O(n^{2})\,$ | quadratic | Multiplying two n-digit numbers by a simple algorithm; bubble sort (worst case or naive implementation), Shell sort, quicksort (worst case), selection sort or insertion sort |
| $O(n^{c}),\;c>1$ | polynomial or algebraic | Tree-adjoining grammar parsing; maximum matching for bipartite graphs |
| $O(c^{n}),\;c>1$ | exponential | Finding the (exact) solution to the travelling salesman problem using dynamic programming; determining if two logical statements are equivalent using brute-force search |
| $O(n!)\,$ | factorial | Solving the travelling salesman problem via brute-force search; generating all unrestricted permutations of a poset; finding the determinant with expansion by minors. |
# A-level Computing 2009/AQA/Problem Solving, Programming, Operating Systems, Databases and Networking/Problem Solving/Big O Notation

* From the Specification : Big-O Notation
* Linear time, polynomial time, exponential time.
* Order of complexity.
Big O Notation (also known as Big-O Notation) is a mathematical way of describing the limiting behaviours of a function. In other words, it is a way of defining how efficient an algorithm is by how "fast" it will run.

## Timing

You can work out the time that an algorithm takes to run by timing it:
However, this isn't always suitable. What happens if you run some code on a 33 MHz processor, and some code on a 3.4 GHz processor. Timing a function tells you a lot about the speed of a computer and very little about the speed of an algorithm.

## Refining algorithms

optimised version

## Order of Complexity

| Notation | Name | Example |
| $O(1)\,$ | constant | Determining if a number is even or odd; using a constant-size lookup table |
| $O(\log n)\,$ | logarithmic | Finding an item in a sorted array with a binary search or a balanced search tree as well as all operations in a Binomial heap. |
| $O(n)\,$ | linear | Finding an item in an unsorted list or a malformed tree (worst case) or in an unsorted array; Adding two n-bit integers by ripple carry. |
| $O(n\log n)=O(\log n!)\,$ | linearithmic, loglinear, or quasilinear | Performing a Fast Fourier transform; heapsort, quicksort (best and average case), or merge sort |
| $O(n^{2})\,$ | quadratic | Multiplying two n-digit numbers by a simple algorithm; bubble sort (worst case or naive implementation), Shell sort, quicksort (worst case), selection sort or insertion sort |
| $O(n^{c}),\;c>1$ | polynomial or algebraic | Tree-adjoining grammar parsing; maximum matching for bipartite graphs |
| $O(c^{n}),\;c>1$ | exponential | Finding the (exact) solution to the travelling salesman problem using dynamic programming; determining if two logical statements are equivalent using brute-force search |
| $O(n!)\,$ | factorial | Solving the travelling salesman problem via brute-force search; generating all unrestricted permutations of a poset; finding the determinant with expansion by minors. |
# A-level Computing 2009/AQA/Problem Solving, Programming, Operating Systems, Databases and Networking/Problem Solving/Reverse Polish Notation

Reverse Polish notation (otherwise known as post-fix, RPN for short) is a way of representing mathematical equations. The notation is used because the format that the equation is in is easier for machines to interpret rather than the notation we are used to, infix notation, where the operator is in between the numbers. The equation can be complex or simple. RPN doesnt require brackets as the equations are layed out in such a format that it isn't required for machines to understand.
The name RPN is named after Jan Łukasiewicz, a Polish logician who invented Polish notation (prefix notation) some time in the 1920s.

## Reverse Polish Notation

Reverse polish notation should be ordered like this:
Rather than the normal convention(infix) of:

## Examples
### Examples of equivalent equations

| PostFix | Infix | Answer |
| 3 4 + | 3 + 4 | 7 |
| 3 5 6 + * | (5 + 6) * 3 | 33 |
| 2 4 / 5 6 - * | (2/4)*(5-6) | -0.5 |
| 2 3 ↑ | 2³ | 8 |

### YouTube Video Example

A video example can be seen here from Computerphile on Youtube: https://www.youtube.com/watch?v=7ha78yWRDlE

## Practice Questions

* Exercise: Infix to RPN Conversion.
* Convert x + y into RPN.
* Answer:
* x y +
* Convert (x + y)*z into RPN.
* Answer:
* x y + z *
* Convert 3 / (5 + y * x) into RPN.
* Answer:
* 3 5 y x * + /
* Exercise: RPN to Infix Conversion
* Convert x y * into infix.
* Answer:
* x * y
* Convert 5 y + z x 3 - * / into infix.
* Answer:
* (5 + y) / (z * (x - 3))

## References

* ↑ Video link to Computerphile a Youtube channel: https://www.youtube.com/channel/UC9-y-6csu5WGm29I7JiwpnA
# A-level Computing 2009/AQA/Problem Solving, Programming, Operating Systems, Databases and Networking/Programming Concepts/Binary search

Binary search locates the position of an item in a sorted array.
A quick way to remember how this search works is to imagine searching for words beginning with 'S' in a dictionary. You know that the dictionary is in alphabetical order but you don't yet know if there are any words beginning with 'S' in it, nor do you know where the 'S' section begins and ends.
| Description | Traced Alphabet |
| Open the Dictionary in the centre - you find the letter 'L' Letters before 'L' aren't any good, so ignore that part of the dictionary Taking the 'L' to 'Z' section, you split it in half and find 'P' Letters before 'P' aren't any good, so ignore that part of the dictionary Taking the 'P' to 'Z' section, you split it in half and find 'U' Letters after 'U' aren't any good, so ignore that part of the dictionary Taking the 'P' to 'U' section, you split it in half and find 'S' | abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz |
how efficient is it? how many searches for x number of items? what is the equation? give an example. Why is it better than a linear search. Can you use it on ordered lists or unordered lists?
How to work out the maximum number of searches (n) on a x sized array:
For example, if we had a 3 item array
Note: This code assumes 1-based array indexing. For languages that use 0-based indexing (most modern languages), min and max should be initialized to 0 and N-1.
Note 2: The code above does not return a result, nor indicates whether the element was found or not.
Note 3: The code above will not work correctly for empty arrays, because it attempts to access an element before checking to see if min > max.
* Exercise: Binary Search
* Given a 256 item sorted list, what is the maximum number of searches needed to find an item?
* Answer:
* 9 as:
* 2^n > size of list where n = max searches
* 2^9 = 512 > 256
* Given a 1000 item sorted list, what is the maximum number of searches needed to find an item?
* Answer:
* 10 as:
* 2^n > size of list where n = max searches
* 2^10 = 1024 > 1000
# 2011 Exam

The exam questions are very hard to predict and this site is by no means going to give you everything you need for the questions you'll sit. The most important thing you should do is learn how to program, and learn how to program well!

## Things to Learn

Reading the specification it appears that you will have to learn the following:
* File Read
* File Write
* String manipulation
* Random functions

## The Exam

The exam is split into 4 sections that must be completed on a computer.

### Section A

<30 minutes> Theory Questions based on the material you have covered for unit 1. For an overview of what this might include see the specification and this wikibook

### Section B

<20 minutes> Programming solutions to short problems, not based on the preliminary material or skeleton code
* Section B

### Section C

<20 minutes> Theory questions about the preliminary material and skeleton code
* Section C

### Section D

<50 minutes> Program solutions based around the preliminary code. The guidance below doesn't pretend to offer the actual questions that will be set in the exam, but by doing them you should hopefully get a better grasp of the code and be able to answer any questions thrown at you during the exam.
* Section D
# A-level Computing 2009/AQA/Problem Solving, Programming, Data Representation and Practical Exercise/Skeleton code

The exam questions are very hard to predict and this site is by no means going to give you everything you need for the questions you'll sit. The most important thing you should do is learn how to program, and learn how to program well!
* 2015 Exam
* 2014 Exam
* 2013 Exam
* 2012 Exam
* 2011 Exam
# A-level Computing 2009/AQA/Problem Solving, Programming, Data Representation and Practical Exercise/Problem Solving/Structure charts

A Structure Chart in software engineering is a chart which shows the breakdown of a system to its lowest manageable parts. They are used in structured programming to arrange program modules into a tree. Each module is represented by a box, which contains the module's name. The tree structure visualizes the relationships between modules, showing data transfer between modules using arrows. Structured Charts are an example of a top-down design where a problem (the program) is broken into its components.
| Symbol | Name | Meaning |
| Module Name | Process | Each Box represents a programming module, this might be something that calculates the average of some figures, or prints out some pay slips |
| | Data Couple | Data being passed from module to module that needs to be processed. |
| | Flag | [Extension - you don't need to know this for the exam] Check data sent to process to stop or start processes. For example when the End of a File that is being read is reached, or a flag to say whether data sent was in the correct format |
Let's take a look at a simple example of how this might be executed when representing the following code:
* Exercise: Structure Charts
* Create structure charts for the following code:
* sub main
* dim num1 as integer
* dim num2 as integer
* dim avg as integer
* sayHello
* num1 = 34
* num2 = 89
* avg = average(num1, num2)
* end sub
* function average(a,b)
* return (a + b) / 2
* end function
* sub sayHello
* console.writeline("hello")
* end sub
* Answer:

## Selection

A selection in a Structure Chart is determined by the diamond symbol. This means a condition will be checked and depending on the result, different modules will be executed.

## Iteration

Using the semi circular arrow we can represent iteration in Structure Charts. The arrow encompasses a link to a module, implying that module is executed multiple times. Let's take a look at a coded example:
* Exercise: Structure Charts, Iteration and Selection
* Create structure charts for the following code:
* sub howManyThrees
* dim num1, count, total as integer
* num1 = startMsg
* count = 0
* total = 0
* while num1 > 0 do
* checkNumber(count, total, num1)
* num1 = num1 - 1
* end while
* endMsg(count)
* end sub
* sub checkNumber(byRef c, byRef t, byVal n)
* If n MOD 3 = 0 Then
* c = divBy3(c)
* Else
* t = add(n, t)
* EndIf
* end sub
* function divBy3(x)
* return x + 1
* end function
* function add(n, t)
* return n + t
* end function
* function startMsg
* console.writeline("program started, enter your number")
* return console.readline
* end function
* sub endMsg(n)
* console.writeline("number of threes : " & n)
* end sub
* Answer:
# A-level Computing 2009/AQA/Problem Solving, Programming, Data Representation and Practical Exercise/Problem Solving/Top-down design and Step-wise refinement

A top-down approach (also known as stepwise design) is essentially the breaking down of a system to gain insight into the sub-systems that make it up. In a top-down approach an overview of the system is formulated, specifying but not detailing any first-level subsystems. Each subsystem is then refined in yet greater detail, sometimes in many additional subsystem levels, until the entire specification is reduced to base elements. Once these base elements are recognised then we can build these as computer modules. Once they are built we can put them together, making the entire system from these individual components.
* Example: Making Pancakes
* To show you an example of Top-Down design we'll take the act of making pancakes. Starting from the top we have the task to:
* Make some pancakes
* But saying that by itself isn't enough to actually make any pancakes, we need to break the task down:
* Make some pancakes
* Organise Kitchen
* Make Pancakes
* Serve
* Each of these tasks can then be broken down further:
* Organise Kitchen
* Clean surfaces
* Get out mixing bowl, whisk, spoon, sieve
* Get out plain flour, salt, eggs, full fat milk, butter
* Put on apron
* Make Pancakes
* Sift salt and flour into bowl
* Break eggs into bowl
* Whisk
* Add water and milk
* Add butter
* Whisk
* Cook
* Serve
* And each of these tasks can be broken down further, let us take a look at the Cook:
* Cook
* Get pan to temperature
* Pour batter in
* Spread batter to edges
* Use plastic spatula to check bottom of pancake
* When brown, flip
* Use plastic spatula to check bottom of pancake
* When brown finish
* We can break down some of these tasks even further. So starting at a single point, the creation of a pancake, we have broken down the task into it individual parts
* Exercise: Top-down design
* Draw a top-down design tree to three level depth for making a modern First Person Shooter
* Answer:
* Your answer probably won't be the same as this as the question is open to interpretation, but hopefully it'll be similar:
* Make First Person Shooter
* Create graphics
* Characters
* Guns
* Maps
* Interface
* Create sounds
* Music
* SFX
* Create AI
* Non-playable characters
* Monsters
# Ada Programming/Keywords/abs

This keyword is used for the operator that gets the absolute value of a number.

## See also
### Wikibook

* Ada Programming
* Ada Programming/Keywords

### Ada 95 Reference Manual

* 2.9 Reserved Words (Annotated)
* 4.4 Expressions (Annotated)
* 4.5.6 Highest Precedence Operators (Annotated)
* Annex P (informative) Syntax Summary (Annotated)

### Ada 2005 Reference Manual

* 2.9 Reserved Words (Annotated)
* 4.4 Expressions (Annotated)
* 4.5.6 Highest Precedence Operators (Annotated)
* Annex P (informative) Syntax Summary (Annotated)

### Ada Quality and Style Guide

* 3.1.3 Capitalization
* 5.5.3 Parenthetical Expressions
Ada Operators :
| and | and then | > | + | abs | & |
| or | or else | >= | - | mod | |
| xor | = | < | * | rem | in |
| not | /= | <= | ** | / | not in |
# Ada Programming/Keywords/abstract
## Summary

The keyword abstract is used to define an abstract tagged type. See Ada Programming/Object Orientation for details on object orientation in Ada.

## See also
### Wikibook

* Ada Programming
* Ada Programming/Keywords

### Ada Reference Manual

* 2.9 Reserved Words (Annotated)
* Annex P (informative) Syntax Summary (Annotated)
* 3.9.3 Abstract Types and Subprograms (Annotated)

### Ada Quality and Style Guide

* 3.1.3 Capitalization
# Ada Programming/Function overloading
## Description

Function overloading (also method overloading) is a programming concept that allows programmers to define two or more functions with the same name and in the same scope.
Each function has a unique signature (or header), which is derived from:
* function/procedure name
* number of arguments
* arguments' type
* arguments' order
* arguments' name
* return type
Please note: Not all above signature options are available in all programming languages.
Available functions overloadings :
| Language | 1 | 2 | 3 | 4 | 5 | 6 |
| Ada | yes | yes | yes | yes | yes | yes |
| C++ | yes | yes | yes | yes | no | no |
| Java | yes | yes | yes | yes | no | no |
| Swift | yes | yes | yes | yes | yes | yes |
Warning: Function overloading is often confused with function overriding. In Function overloading, a function with a different signature is created, adding to the pool of available functions. In function overriding, however, a function with the same signature is declared, replacing the old function in the context of the new function.

## Demonstration

Since functions' names are in this case the same, we must preserve uniqueness of signatures, by changing something from the parameter list (last three alienees).
If the functions' signatures are sufficiently different, the compiler can distinguish which function was intended to be used at each occurrence. This process of searching for the appropriate function is called function resolution and can be quite an intensive one, especially if there are a lot of equally named functions.
Programming languages supporting implicit type conventions usually use promotion of arguments (i.e. type casting of integer to floating-point) when there is no exact function match. The demotion of arguments is rarely used.
When two or more functions match the criteria in function resolution process, an ambiguity error is reported by compiler. Adding more information for the compiler by editing the source code (using for example type casting), can address such doubts.
The example code shows how function overloading can be used. As functions do practically the same thing, it makes sense to use function overloading.

### calling the first function

The first code block will generate numbers from 0 up to specified parameter MaxValue. The appropriate function call is:

### calling the second function

The second requires another parameter MinValue. Function will return numbers above or equals MinValue and lower than MaxValue.

## Function overloading in Ada

Ada supports all six signature options, but if you use the arguments' name as option, you will always have to name the parameter when calling the function. i.e.:
Note that you cannot overload a generic procedure or generic function within the same package. The following example will fail to compile:

## See also
### Wikibook

* Ada Programming
* Ada Programming/Subprograms

### Ada 95 Reference Manual

* 6.6: Overloading of Operators
* 8.6: The Context of Overload Resolution

### Ada 2005 Reference Manual

* 6.6: Overloading of Operators
* 8.6: The Context of Overload Resolution
# Ada Programming/Keywords
## Language summary keywords

Most Ada “keywords” have different functions depending on where they are used. A good example is for which controls the representation clause when used within a declaration part and controls a loop when used within an implementation.
In Ada, a keyword is a reserved word, so it cannot be used as an identifier. Some of them are used as attribute names.

## See also
### Wikibook

* Ada Programming
* Ada Programming/Aspects
* Ada Programming/Attributes
* Ada Programming/Pragmas

### Ada Reference Manual
#### Ada 83

* 2.9: Reserved Words
* Annex E: Syntax Summary

#### Ada 95

* 2.9: Reserved Words
* Annex P: (informative) Syntax Summary

#### Ada 2005

* 2.9: Reserved Words
* Annex P: (informative) Syntax Summary

#### Ada 2012

* 2.9: Reserved Words
* Annex P: (informative) Syntax Summary

#### Ada 2022

* 2.9: Reserved Words
* Annex P: (informative) Syntax Summary

### Ada Quality and Style Guide

* 3.1.3 Capitalization
# Ada Programming/Keywords/abort
## abort

The abort is used to abort either a task (thread) or partition (process).

## See also
### Wikibook

* Ada Programming
* Ada Programming/Keywords
* Ada Programming/Tasking

### Ada Reference Manual

* 2.9 Reserved Words (Annotated)
* Annex P (informative) Syntax Summary (Annotated)
* 9.8 Abort of a Task - Abort of a Sequence of Statements (Annotated)
* E.1 Partitions (Annotated)

### Ada Quality and Style Guide

* 3.1.3 Capitalization
# A-level Physics (Advancing Physics)/Current

Current is the amount of charge (on particles such as electrons) flowing through part of an electric circuit per second. Current is measured in amperes (usually abbreviated A), where 1 ampere is 1 coulomb of charge per second. The formula for current is:
$I={\frac {\Delta Q}{\Delta t}}$ ([The triangle (Greek letter delta) means change in the quantity])
where I is current (in A), Q is charge (in C) and t is the time it took for the charge to flow (in seconds).
In a series circuit, the current is the same everywhere in the circuit, as the rate of flow of charged particles is constant throughout the circuit. In a parallel circuit, however, the current is split between the branches of the circuit, as the number of charged particles flowing cannot change. This is Kirchoff's First Law, stating that:
In mathematical form:
$\sum I_{in}=\sum I_{out}$ (The character that resembles a sideways M is the Greek letter sigma, meaning 'sum of'.)

## Questions

1. 10 coulombs flow past a point in a wire in 1 minute. How much current is flowing through the point?
2. How long does it take for a 2A current to carry 5C?
3. In the diagram on the left, I = 9A, and I$_1$ = 4.5A. What is the current at I$_2$?
4. What would I equal if I$_1$ = 10A and I$_2$ = 15A?
5. In the diagram on the left, in 5 seconds, 5C of charged particles flow past I$_1$, and 6.7C flow past I$_2$. How long does it take for 10C to flow past I?
Worked Solutions
# A-level Physics (Advancing Physics)/Damping/Worked Solutions

1. Draw a graph of displacement for a critically damped oscillation.
2. How would you critically damp an oscillating pendulum?
Grab the weight, move it to its equilibrium position, and stop it moving.
3. How would you damp an oscillating pendulum using only a weighted polystyrene block?
Put the block in the path of the pendulum, which will bounce off the weight, losing a bit of energy each oscillation.
4. What would the displacement graph look like for this oscillation, before and after damping began?
5. The graph above is an exponentially damped oscillation. If the displacement of the undamped oscillation is given by sin ωt, what is an approximate equation for the damped oscillation, in terms of a constant k which describes the degree to which the oscillation is damped?
$x=e^{-k\omega t}\sin {\omega t}$
If k doubles, the e$^{-kt}$ will be squashed to half its size along the t-axis, so as k increases, the rate of damping increases.