Skip to content

18.1 Artificial Intelligence

A Level · 25 questions found

  • Graphs in AI: structure and purpose; use A* and Dijkstra’s for AI searches
  • Artificial neural networks and machine learning
  • Deep Learning, Machine Learning and Reinforcement Learning — why each is used
  • ML categories: supervised learning vs unsupervised learning
  • Back propagation of errors; regression methods in machine learning
Q7
Oct/Nov 2025 Paper 1 v3

A digital video camera records students in a classroom. The data is transferred from the digital video camera over the internet to a server. Artificial Intelligence (AI) is used to analyse the video on the server to identify when students are interacting with the lesson and the teacher.

(a) Describe one ethical impact of this use of AI in the classroom. 2 marks

(b) A video is made of many bitmap images called frames. 30 frames are recorded every second. 2 marks

Each frame is 4000 pixels wide by 3000 pixels high. The video records using 16‑bit colour depth.

Calculate an estimate for the file size for one second of the video in gigabytes.

Show your working.

File size ______ gigabytes

(c) Identify and describe one method of data verification that can be used when transferring data from the digital video camera to the server. 3 marks

Method

Description

(d) Describe two reasons why the server that stores the videos uses magnetic hard disks instead of solid state (flash) memory. 4 marks

1

2

(e) The table contains three algorithms that perform data validation. The third algorithm uses the functions MID and LENGTH. 3 marks

The functions MID and LENGTH are defined as follows:

  • MID(ThisString : STRING, x : INTEGER, y : INTEGER) RETURNS STRING returns a string of length y starting at position x from ThisString

  • LENGTH(ThisString : STRING) RETURNS INTEGER returns the integer value representing the length of ThisString

Complete the table to identify the method of data validation for each algorithm. Each method of data validation must be different.

Algorithm Method of data validation
INPUT x
IF x < 1 or x > 26 THEN
OUTPUT "Invalid"
ENDIF
INPUT x
IF x <> 'R' AND x <> 'G' AND x <> 'B' THEN
OUTPUT "Invalid"
ENDIF
INPUT x
FLAG
FALSE
FOR INDEX
1 TO LENGTH(x)
IF MID(x, INDEX, 1) = "@" THEN
FLAG
TRUE
ENDIF
NEXT INDEX
IF NOT FLAG THEN
OUTPUT "Invalid"

ENDIF
A digital video camera records students in a classroom. The data is transferred from the digital video camera over the internet to a server. Artificial Intelligence (AI) is used to analyse the video on the server to identify when students are interacting with the lesson and the teacher. ### (a) Describe one ethical impact of this use of AI in the classroom. <span class="part-marks">2 marks</span> ### (b) A video is made of many bitmap images called frames. 30 frames are recorded every second. <span class="part-marks">2 marks</span> Each frame is 4000 pixels wide by 3000 pixels high. The video records using 16‑bit colour depth. Calculate an estimate for the file size for one second of the video in gigabytes. Show your working. File size ______ gigabytes ### (c) Identify and describe one method of data verification that can be used when transferring data from the digital video camera to the server. <span class="part-marks">3 marks</span> Method Description ### (d) Describe two reasons why the server that stores the videos uses magnetic hard disks instead of solid state (flash) memory. <span class="part-marks">4 marks</span> 1 2 ### (e) The table contains three algorithms that perform data validation. The third algorithm uses the functions MID and LENGTH. <span class="part-marks">3 marks</span> The functions MID and LENGTH are defined as follows: - MID(ThisString : STRING, x : INTEGER, y : INTEGER) RETURNS STRING returns a string of length y starting at position x from ThisString - LENGTH(ThisString : STRING) RETURNS INTEGER returns the integer value representing the length of ThisString Complete the table to identify the method of data validation for each algorithm. Each method of data validation must be different. |Algorithm|Method of data validation| |---|---| |INPUT x<br>IF x < 1 or x > 26 THEN<br> OUTPUT "Invalid"<br>ENDIF|| |INPUT x<br>IF x <> 'R' AND x <> 'G' AND x <> 'B' THEN<br> OUTPUT "Invalid"<br>ENDIF|| |INPUT x<br>FLAG<br> FALSE<br>FOR INDEX<br> 1 TO LENGTH(x)<br> IF MID(x, INDEX, 1) = "@" THEN<br> FLAG<br> TRUE<br> ENDIF<br>NEXT INDEX<br>IF NOT FLAG THEN<br> OUTPUT "Invalid"<br> <br>ENDIF||
Show mark scheme

7(a) [2 marks]

1 mark per point, max 2 marks e.g. • The learning experience could be improved • … by identifying students who are struggling • …. and employing more personalised learning • There could be early Intervention • … to determine which students require extra support • • Teachers and students could understand the challenges better • …and identify optimal times for learning • There could be privacy concerns • …. students / teachers could be uncomfortable with constant surveillance • ... students might not want their data / actions passed to third parties • There could be Mental Health concerns • …. due to constant monitoring and pressure • …. contributing to student stress and anxiety

7(b) [2 marks]

1 mark for the working 1 mark for the correct answer Working: (400030003016) / (8100010001000) //(40003000302) / (10001000*1000) Answer: 0.72 gigabytes

7(c) [3 marks]

1 mark for the name 2 marks for the matching description, max 3 marks • Parity Byte Check • a parity bit is added to each byte to make the number of 1s match the parity, odd or even • each byte can be checked on receipt and request to be resent if the byte does not match parity • Parity Block Check • a bit is added to each byte, but a parity byte is also set for each block • the location of an error can be found using vertical and horizontal parity • Checksum • A calculation is made from the data and transmitted with the data • The receiver performs the same calculation and compares with received checksum to see if they match

7(d) [4 marks]

1 mark per reason, 1 mark for corresponding justification x2 max 4 marks • Lower cost per unit of storage • ... so the high capacity of storage required for large number of video files will be less costly • A large number of read/write operations are being performed continuously • ... and magnetic storage is likely to have a longer life span compared with solid state

7(e) [3 marks]

1 mark for each validation check correctly identified, max 3 marks Range Check Existence Check Format Check

Q7
Oct/Nov 2025 Paper 3 v1

(a) Identify one Artificial Intelligence (AI) algorithm to find the shortest distance between two points on a graph. 1 mark

(b) Describe Deep Learning. 5 marks

### (a) Identify one Artificial Intelligence (AI) algorithm to find the shortest distance between two points on a graph. <span class="part-marks">1 mark</span> ### (b) Describe Deep Learning. <span class="part-marks">5 marks</span>
Show mark scheme

7(a) [1 mark]

One from: • A* algorithm • Dijkstra’s algorithm

7(b) [5 marks]

One mark for each mark point ( Max 5 ) MP1 Deep learning is a branch of machine learning MP2 It makes use of artificial neural networks MP3 … to work in a similar manner to the human/biological brain // … neural networks can be trained to process data MP4 It is a structure consisting of many interconnected layers MP5 … input, hidden and output // the input layer feeds the first hidden layer, the last hidden layer feeds the output MP6 … gradually breaking down and analysing the data to find (hidden) patterns MP7 Deep leaning’s feature extraction/learning involves how to detect features/categories from data MP8 … and can involve different types of supervision MP9 It works well with large data sets MP10 Deep learning uses back propagation of errors to adjust parameters/weightings to refine its results / improve its accuracy.

Q9
Oct/Nov 2025 Paper 3 v2

(a) Deep Learning is a form of Machine Learning.

(i) State one example where Deep Learning is used. 1 mark

(ii) Identify how Deep Learning can be made more effective. 1 mark

(b) Describe the back propagation of errors method in Machine Learning. 4 marks

### (a) Deep Learning is a form of Machine Learning. #### (i) State one example where Deep Learning is used. <span class="part-marks">1 mark</span> #### (ii) Identify how Deep Learning can be made more effective. <span class="part-marks">1 mark</span> ### (b) Describe the back propagation of errors method in Machine Learning. <span class="part-marks">4 marks</span>
Show mark scheme

9(a)(i) [1 mark]

One from: e.g. • Virtual assistants // AI Agents • Chatbots • Composing music • Self-driving cars • Natural language processing • Fraud detection • Image colouring // photograph enhancement • Visual/Image recognition/facial recognition • Text mining • Computer assisted translation • Large language models (LLMs) • Playing chess • Grading student exams • Weather forecasting

9(a)(ii) [1 mark]

Use / introduce more hidden layers

9(b) [4 marks]

One mark per mark point ( Max 4 ) MP1 Initial outputs are compared to expected outputs MP2 … weightings are adjusted to minimise the difference between actual and expected outputs MP3 Calculus is used to find the error gradient in the obtained outputs MP4 … the results are fed back into the neural network MP5 … weightings of each neuron / node are adjusted as a result of the feedback MP6 … the process repeats until results are more accurate

Q8
Oct/Nov 2025 Paper 3 v3

Calculate the shortest distance between the Start node and each of the nodes in the graph using Dijkstra’s algorithm.

Show your working on the graph or in the working space. Write your answers in the table provided.

Working

Answers: 5 marks

T V W X Y Z
Calculate the shortest distance between the Start node and each of the nodes in the graph using Dijkstra’s algorithm. Show your working on the graph or in the working space. Write your answers in the table provided. ![](../images/w25_33_q8_fig1.png) Working Answers: <span class="part-marks">5 marks</span> |T|V|W|X|Y|Z| |---|---|---|---|---|---| |||||||
Show mark scheme

8 [5 marks]

One mark per mark point - working ( Max 3 ) May be seen on diagram or in working section MP1 Initialisation – setting Start to 0  MP2 … and the rest of the towns to MP3 Evidence to show values at nodes being updated MP4 Evidence to show ‘visited node(s)’ MP5 Evidence to show a correct calculation of at least one route MP6 Evidence to show more than one route has been calculated for at least one town Correct Answers ( Max 2 ) Two marks for all six correct values One mark for four or five correct values. 6 10 13 18 21 28

Q4
May/Jun 2025 Paper 1 v1

A shop installs a new system that allows users to purchase items without going through a manual checkout.

The new system:

  • identifies customers when they enter the shop and matches them to their account

  • prevents a customer from walking through the automatic barriers if they do not have an account

  • automatically detects the items that a customer has taken from a shelf and charges these to the customer’s account.

(a) The new system uses digital cameras and Artificial Intelligence (AI) to identify the customers. 4 marks

Explain how the new system uses AI to identify each customer.

(b) The new system uses sensors to identify the items taken from a shelf. 2 marks

Identify one type of sensor that can be used in this new system.

State how the sensor can be used to identify the items taken from a shelf.

Sensor

Use

A shop installs a new system that allows users to purchase items without going through a manual checkout. The new system: - identifies customers when they enter the shop and matches them to their account - prevents a customer from walking through the automatic barriers if they do not have an account - automatically detects the items that a customer has taken from a shelf and charges these to the customer’s account. ### (a) The new system uses digital cameras and Artificial Intelligence (AI) to identify the customers. <span class="part-marks">4 marks</span> Explain how the new system uses AI to identify each customer. ### (b) The new system uses sensors to identify the items taken from a shelf. <span class="part-marks">2 marks</span> Identify one type of sensor that can be used in this new system. State how the sensor can be used to identify the items taken from a shelf. Sensor Use
Show mark scheme

4(a) [4 marks]

1 mark each to max 4 e.g. • Uses image recognition / facial recognition • Measures the distance between facial features of the customer • and stores the values in a database of user information • An image is captured using the digital camera • the AI identifies that the image is a face • by analysing the pixels to find patterns • the distance between features is calculated and compared to those in database

4(b) [2 marks]

1 mark for sensor, 1 mark for corresponding use e.g. Sensor Use Pressure Detects when the pressure of an item is removed from a shelf / put back on a shelf Infrared Detects when the beam is broken for an item removed / added

Q3
May/Jun 2025 Paper 1 v2

A computer program uses a digital camera to read the words on an item.

The program can read the words that are written on the item, translate the words to a chosen language and then output the words as audio. For example, when used in a supermarket, the program can output the words written on the labels on products.

The program uses Artificial Intelligence (AI).

(a) Explain how AI is used in the computer program described. 4 marks

(b) State two social benefits of the use of AI in the computer program described. 2 marks

1

2

A computer program uses a digital camera to read the words on an item. The program can read the words that are written on the item, translate the words to a chosen language and then output the words as audio. For example, when used in a supermarket, the program can output the words written on the labels on products. The program uses Artificial Intelligence (AI). ### (a) Explain how AI is used in the computer program described. <span class="part-marks">4 marks</span> ### (b) State two social benefits of the use of AI in the computer program described. <span class="part-marks">2 marks</span> 1 2
Show mark scheme

3(a) [4 marks]

1 mark each to max 4 e.g. • Uses image recognition // optical character recognition • to analyse a photograph/pixels to identify the location of characters within an image • in order to convert the pattern of pixels into individual characters • Uses natural language • to combine the characters into words • and compare the words to database to identify a match in the language of the writing • it may also predict what is missing / incomplete / from what has been read • then compare the words to a database of the user’s chosen language to find a match and translate • Uses text-to-speech • to generate the audio waveforms corresponding to the words

3(b) [2 marks]

1 mark each to max 2 e.g. • It can help people with visual impairment to identify which products to purchase • It can help people who cannot understand the language • It can help to overcome learning / reading difficulties

3(c)(i) [3 marks]

1 mark each to max 3 • The program is usually sold for a fee • Users have no access to source code • It protects the intellectual rights of the programmer / developer • Users cannot legally alter or share the program • There are limitations on the use of the software e.g. number of times it can be installed • Support and maintenance is usually provided e.g. updates, bug fixes etc.

3(c)(ii) [3 marks]

1 mark each to max 3 e.g. • The source code would be accessible therefore it could be changed • which might lead to the program outputting an incorrect response • so people could purchase the wrong item • which might have serious consequences // by example e.g. allergies

Q10
May/Jun 2025 Paper 3 v1

(a) Describe the purpose of a graph when used in an Artificial Intelligence (AI) system. 2 marks

(b) Explain the use of artificial neural networks in Deep Learning. 4 marks

### (a) Describe the purpose of a graph when used in an Artificial Intelligence (AI) system. <span class="part-marks">2 marks</span> ### (b) Explain the use of artificial neural networks in Deep Learning. <span class="part-marks">4 marks</span>
Show mark scheme

10(a) [2 marks]

One mark for each mark point ( Max 2 ) MP1 A graph is used in AI to record relationships between entities MP2 … using vertices / nodes and edges MP3 for example, to represent places on a map and the distances between them, in order to find the shortest route.

10(b) [4 marks]

One mark for each mark point ( Max 4 ) MP1 Artificial neural networks are designed to work in the same way as the human brain MP2 ANNs provide the architecture and algorithms for learning from the data MP3 They have a large number of connected processing units / nodes MP4 … that are arranged in layers / interconnected and work together to process data MP5 Deep learning models learn from data by adjusting the weights/biases of the connections between neurons MP6 They use multiple hidden layers to extract complex features and to make predictions

Q10
May/Jun 2025 Paper 3 v3

(a) State the purpose of the A* and Dijkstra’s algorithms. 1 mark

(b) Outline the difference between the A* and Dijkstra’s algorithms. 2 marks

(c) Explain how unsupervised learning takes place in machine learning. 3 marks

### (a) State the purpose of the A* and Dijkstra’s algorithms. <span class="part-marks">1 mark</span> ### (b) Outline the difference between the A* and Dijkstra’s algorithms. <span class="part-marks">2 marks</span> ### (c) Explain how unsupervised learning takes place in machine learning. <span class="part-marks">3 marks</span>
Show mark scheme

10(a) [1 mark]

To find the path between two points on a graph using the algorithm.

10(b) [2 marks]

One mark per point ( Max 2 ) MP1 A* tries to find a better path (between two points) by using a heuristic function // A* finds the adjacent route with the shortest path and continues this until the destination is reached MP2 … Dijkstra’s just explores all possible routes. MP3 The heuristic function on the A* algorithm gives priority to nodes that are supposed to be better than others / less costly than others. MP4 Dijkstra’s algorithm cannot work with negative values/weights //A* algorithm can work with negative values/weights.

10(c) [3 marks]

One mark for each mark point ( Max 3 ) MP1 Unsupervised learning uses algorithms to analyse / cluster MP2 … unlabelled data sets MP3 They discover hidden patterns / data groupings / clusters without the need for human intervention. MP4 It is able to discover similarities and differences in data / information.

Q6
Oct/Nov 2024 Paper 1 v1

A car park system uses a camera to record the registration number of each car as it enters and leaves the car park.

Explain how artificial intelligence is used in the car park system to identify the car’s registration number. 4 marks

A car park system uses a camera to record the registration number of each car as it enters and leaves the car park. Explain how artificial intelligence is used in the car park system to identify the car’s registration number. <span class="part-marks">4 marks</span>
Show mark scheme

6 [4 marks]

1 mark for each bullet point ( max 4 ) e.g. • It uses image recognition • The pixels of each image from the camera are stored • … and matched to the expected shape/size/colour of registration number • It uses optical character recognition • The pixels within the registration number area identified are analysed • … and compared to expected characters/letters/numbers

Q9
May/Jun 2024 Paper 3 v1

Explain what is meant by Deep Learning in relation to Artificial Intelligence (AI). 3 marks

Explain what is meant by **Deep Learning** in relation to Artificial Intelligence (AI). <span class="part-marks">3 marks</span>
Show mark scheme

9 [3 marks]

mark per mark point ( Max 3 ) Deep learning learns by finding hidden patterns that are undetectable to humans . It structures algorithms in layers: input layer, hidden layers and output layer. … to create an artificial neural network to learn and make intelligent decisions on its own. It is trained using large quantities of unlabelled data. Deep learning requires/uses a large number of hidden layers. … the larger the number of layers, the higher the level of success.

Q11
May/Jun 2024 Paper 3 v2

Explain what is meant by Reinforcement Learning in relation to Artificial Intelligence. 3 marks

Explain what is meant by **Reinforcement Learning** in relation to Artificial Intelligence. <span class="part-marks">3 marks</span>
Show mark scheme

11 [3 marks]

mark per mark point ( Max 3 ) Reinforcement learning is a machine learning technique based on feedback / rewards / punishment. … in which an agent learns to behave in an environment by performing the actions and seeing the results of the actions. … for each good action, the agent gets positive feedback / reward and each bad action receives negative feedback / punishment. The agent learns automatically using feedback without any labelled data / specific instructions. Adjust node weightings to achieve the correct outcome. // Using feedback to improve its performance at accomplishing similar tasks.

Q9
May/Jun 2024 Paper 3 v3

Explain what is meant by Deep Learning in relation to Artificial Intelligence (AI). 3 marks

Explain what is meant by **Deep Learning** in relation to Artificial Intelligence (AI). <span class="part-marks">3 marks</span>
Show mark scheme

9 [3 marks]

mark per mark point ( Max 3 ) Deep learning learns by finding hidden patterns that are undetectable to humans . It structures algorithms in layers: input layer, hidden layers and output layer. … to create an artificial neural network to learn and make intelligent decisions on its own. It is trained using large quantities of unlabelled data. Deep learning requires/uses a large number of hidden layers. … the larger the number of layers, the higher the level of success.

Q12
Oct/Nov 2023 Paper 3 v1

Artificial neural networks have played a significant role in the development of machine learning.

Explain what is meant by the term artificial neural network . 4 marks

Artificial neural networks have played a significant role in the development of machine learning. Explain what is meant by the term **artificial neural network** . <span class="part-marks">4 marks</span>
Show mark scheme

12 [4 marks]

One mark per mark point ( Max 4 ) MP1 An artificial neural network is the component of artificial intelligence that is meant to simulate the functioning of a biological brain. MP2 Artificial neural networks are a key component of machine learning. MP3 They can solve problems that would prove impossible or difficult for humans // Artificial neural networks have self-learning capabilities that enable them to produce better results as more data becomes available MP4 Artificial neural networks can be layered (input, hidden and output layers) // Artificial neural networks have many interconnected layers, some / many of which are hidden MP5 Weights are assigned between nodes MP6 Weights are adjusted through training to give a more accurate result MP7 More complex learning capabilities / more accurate results are available with larger numbers of hidden layers

Q12
Oct/Nov 2023 Paper 3 v3

Artificial neural networks have played a significant role in the development of machine learning.

Explain what is meant by the term artificial neural network . 4 marks

Artificial neural networks have played a significant role in the development of machine learning. Explain what is meant by the term **artificial neural network** . <span class="part-marks">4 marks</span>
Show mark scheme

12 [4 marks]

One mark per mark point ( Max 4 ) MP1 An artificial neural network is the component of artificial intelligence that is meant to simulate the functioning of a biological brain. MP2 Artificial neural networks are a key component of machine learning. MP3 They can solve problems that would prove impossible or difficult for humans // Artificial neural networks have self-learning capabilities that enable them to produce better results as more data becomes available MP4 Artificial neural networks can be layered (input, hidden and output layers) // Artificial neural networks have many interconnected layers, some / many of which are hidden MP5 Weights are assigned between nodes MP6 Weights are adjusted through training to give a more accurate result MP7 More complex learning capabilities / more accurate results are available with larger numbers of hidden layers

Q2
May/Jun 2023 Paper 3 v1

(a) Draw one line from each machine learning category to its most appropriate description. 4 marks

Machine learning category Description

simulates the data-processing capabilities of the human brain to make decisions

Supervised learning

Reinforcement learning

Deep learning

Unsupervised learning

enables learning by mapping an input to an output based on example input– output pairs

enables information related to errors produced by the neural network to be transmitted

enables learning in an interactive environment by trial and error using its own experiences

enables learning by allowing the process to discover patterns on its own that were previously undetected

(b) Describe the purpose of both the A* algorithm and Dijkstra’s algorithm. 2 marks

### (a) Draw **one** line from each machine learning category to its **most appropriate** description. <span class="part-marks">4 marks</span> **Machine learning category** **Description** simulates the data-processing capabilities of the human brain to make decisions Supervised learning Reinforcement learning Deep learning Unsupervised learning enables learning by mapping an input to an output based on example input– output pairs enables information related to errors produced by the neural network to be transmitted enables learning in an interactive environment by trial and error using its own experiences enables learning by allowing the process to discover patterns on its own that were previously undetected ### (b) Describe the purpose of both the A* algorithm and Dijkstra’s algorithm. <span class="part-marks">2 marks</span>
Show mark scheme

2(a)

One mark for each correct line connecting a machine learning technique to its most appropriate description ( Max 4 ). Machine learning category Description simulates the data processing capabilities of the human brain to make decisions Supervised learning enables learning by mapping an input to an output based on example input- output pairs Reinforcement learning enables information related to errors produced by the neural network to be transmitted Deep learning enables learning in an interactive environment by trial and error using its own experiences Unsupervised learning enables learning by allowing the process to discover patterns on its own that were previously undetected

2(b) [2 marks]

One mark per mark point ( Max 2 )  to find the optimal / shortest / most cost-effective route  … between two nodes in a  … based on distance / cost / time.

Q2
May/Jun 2023 Paper 3 v3

(a) Draw one line from each machine learning category to its most appropriate description. 4 marks

Machine learning category Description

simulates the data-processing capabilities of the human brain to make decisions

Supervised learning

Reinforcement learning

Deep learning

Unsupervised learning

enables learning by mapping an input to an output based on example input– output pairs

enables information related to errors produced by the neural network to be transmitted

enables learning in an interactive environment by trial and error using its own experiences

enables learning by allowing the process to discover patterns on its own that were previously undetected

(b) Describe the purpose of both the A* algorithm and Dijkstra’s algorithm. 2 marks

### (a) Draw **one** line from each machine learning category to its **most appropriate** description. <span class="part-marks">4 marks</span> **Machine learning category** **Description** simulates the data-processing capabilities of the human brain to make decisions Supervised learning Reinforcement learning Deep learning Unsupervised learning enables learning by mapping an input to an output based on example input– output pairs enables information related to errors produced by the neural network to be transmitted enables learning in an interactive environment by trial and error using its own experiences enables learning by allowing the process to discover patterns on its own that were previously undetected ### (b) Describe the purpose of both the A* algorithm and Dijkstra’s algorithm. <span class="part-marks">2 marks</span>
Show mark scheme

2(a)

One mark for each correct line connecting a machine learning technique to its most appropriate description ( Max 4 ). Machine learning category Description simulates the data processing capabilities of the human brain to make decisions Supervised learning enables learning by mapping an input to an output based on example input- output pairs Reinforcement learning enables information related to errors produced by the neural network to be transmitted Deep learning enables learning in an interactive environment by trial and error using its own experiences Unsupervised learning enables learning by allowing the process to discover patterns on its own that were previously undetected

2(b) [2 marks]

One mark per mark point ( Max 2 )  to find the optimal / shortest / most cost-effective route  … between two nodes in a  … based on distance / cost / time.

Q11
Oct/Nov 2022 Paper 3 v1

12 (a) The array Names[0:99] is in alphabetical order.

Complete this pseudocode binary search algorithm.

    Lower  0
# ←
    Mid  0
# ←
    Exit  FALSE
# ←
    OUTPUT "Enter the name to be found "
    INPUT Target
    REPEAT

______ THEN

    OUTPUT Target, " does not exist"
    Exit  TRUE
# ←
    ENDIF
    Mid  Lower + (Upper – Lower + 1) DIV 2
# ←
    IF Names[Mid] < Target THEN

Lower

    ENDIF
    IF Names[Mid] > Target THEN
    ENDIF

______ THEN

    OUTPUT Target, " was found at location ", Mid
    Exit  TRUE
# ←
    ENDIF

6 marks

(b) Big O notation is used to classify efficiency of algorithms.

The Big O notation for time complexity in a binary search is O(log n).

(i) State the Big O notation for time complexity of a linear search. 1 mark

(ii) Describe the meaning of O(log n) as it applies to a binary search algorithm. 2 marks

**12 (a)** The array `Names[0:99]` is in alphabetical order. Complete this pseudocode binary search algorithm. ``` Lower 0 # ← ``` ``` Mid 0 # ← Exit FALSE # ← OUTPUT "Enter the name to be found " INPUT Target REPEAT ``` ______ `THEN` ``` OUTPUT Target, " does not exist" Exit TRUE # ← ENDIF Mid Lower + (Upper – Lower + 1) DIV 2 # ← IF Names[Mid] < Target THEN ``` `Lower` # ← ``` ENDIF IF Names[Mid] > Target THEN ``` ``` ENDIF ``` ______ `THEN` ``` OUTPUT Target, " was found at location ", Mid Exit TRUE # ← ENDIF ``` <span class="part-marks">6 marks</span> ### (b) Big O notation is used to classify efficiency of algorithms. The Big O notation for time complexity in a binary search is O(log n). #### (i) State the Big O notation for time complexity of a linear search. <span class="part-marks">1 mark</span> #### (ii) Describe the meaning of O(log n) as it applies to a binary search algorithm. <span class="part-marks">2 marks</span>
Show mark scheme

11(a) [3 marks]

One mark for each correct OOP term definition: • Instance – an occurrence of an object // a specific object based on the class // an instantiation of a class. • Inheritance – the capability of defining a new class of objects that has all the attributes and methods from a parent class. • Polymorphism – allows the same method to take on different behaviours depending on which class is instantiated // methods can be redefined for derived classes.

11(b) [5 marks]

One mark for each point: • and Car ENDCLASS • Four declarations – must use the identifiers used in the assignments • Constructor header – must use CarBodyType • Two assignments – must use CarMake • Constructor identifier for the car model and the identifier in the Model assignment statement match CLASS Car PRIVATE Make : STRING PRIVATE Model : STRING PRIVATE BodyType : STRING PRIVATE Fuel : STRING PRIVATE NumberBuilt : INTEGER PUBLIC PROCEDURE NEW (CarMake : STRING, CarModel : STRING , CarBodyType : STRING )  Make CarMake  Model CarModel  BodyType CarBodyType  Fuel ""  NumberBuilt 0 ENDPROCEDURE getFuel() getNumberBuilt() ENDCLASS

Q11
Oct/Nov 2022 Paper 3 v2

(b) Complete the pseudocode algorithm so that it achieves the following when applied to the arrays: 5 marks

  • The flower name is input.

  • The linked list is searched, in order, for the flower name.

  • If the flower name is found, an appropriate message is output to indicate it has been found.

  • If the flower name is not found, an appropriate message is output to indicate it has not been found.

  • The algorithm terminates when the next pointer value is 0.

    Pointer  HeadPointer
    Found  0
    OUTPUT "Enter a flower name "

………………………………………………………………….

………………………………………………………………….

    IF Flower[Pointer] = FlowerName THEN
    Found  Pointer
    Pointer  0
    ELSE

………………………………………………………………….

    ENDIF
    ENDWHILE

………………………………………………………………….

    OUTPUT Flower[Found], " is found"
    ELSE

………………………………………………………………….

    ENDIF

(c) Explain how you could improve the simplified linked list structure. 2 marks

### (b) Complete the pseudocode algorithm so that it achieves the following when applied to the arrays: <span class="part-marks">5 marks</span> - The flower name is input. - The linked list is searched, in order, for the flower name. - If the flower name is found, an appropriate message is output to indicate it has been found. - If the flower name is not found, an appropriate message is output to indicate it has not been found. - The algorithm terminates when the next pointer value is 0. ``` Pointer HeadPointer Found 0 OUTPUT "Enter a flower name " ``` …………………………………………………………………. …………………………………………………………………. ``` IF Flower[Pointer] = FlowerName THEN Found Pointer Pointer 0 ELSE ``` …………………………………………………………………. ``` ENDIF ENDWHILE ``` …………………………………………………………………. ``` OUTPUT Flower[Found], " is found" ELSE ``` …………………………………………………………………. ``` ENDIF ``` ### (c) Explain how you could improve the simplified linked list structure. <span class="part-marks">2 marks</span>
Show mark scheme

11(a) [3 marks]

One mark for each point • Correct HeadPointer • Any three correct NextPointer • All six correct NextPointer HeadPointer 5 Index Flower NextPointer 1 Rose 0 2 Marigold 3 Foxglove 4 4 Iris 9 5 Daisy 3 6 Dahlia 7 Saxifrage 8 Lupin 1 9 Lily 8 10 Hydrangea

11(b) [5 marks]

One mark for each correct line  Pointer HeadPointer  Found 0 OUTPUT "Enter a flower name " INPUT FlowerName WHILE Pointer <> 0 IF Flower[Pointer] = FlowerName THEN  Found Pointer  Pointer 0 ELSE  Pointer NextPointer[Pointer] ENDIF ENDWHILE IF Pointer = 0 THEN // IF Found <> 0 THEN OUTPUT Flower[Found], " is found" ELSE OUTPUT "The flower you wanted is not in the list" ENDIF

11(c) [2 marks]

One mark for each point ( Max 2 ) • Include a free list pointer • …to reuse the unused space • …as a linked list of free space.

Q11
Oct/Nov 2022 Paper 3 v3

12 (a) The array Names[0:99] is in alphabetical order.

Complete this pseudocode binary search algorithm.

    Lower  0
# ←
    Mid  0
# ←
    Exit  FALSE
# ←
    OUTPUT "Enter the name to be found "
    INPUT Target
    REPEAT

______ THEN

    OUTPUT Target, " does not exist"
    Exit  TRUE
# ←
    ENDIF
    Mid  Lower + (Upper – Lower + 1) DIV 2
# ←
    IF Names[Mid] < Target THEN

Lower

    ENDIF
    IF Names[Mid] > Target THEN
    ENDIF

______ THEN

    OUTPUT Target, " was found at location ", Mid
    Exit  TRUE
# ←
    ENDIF

6 marks

(b) Big O notation is used to classify efficiency of algorithms.

The Big O notation for time complexity in a binary search is O(log n).

(i) State the Big O notation for time complexity of a linear search. 1 mark

(ii) Describe the meaning of O(log n) as it applies to a binary search algorithm. 2 marks

**12 (a)** The array `Names[0:99]` is in alphabetical order. Complete this pseudocode binary search algorithm. ``` Lower 0 # ← ``` ``` Mid 0 # ← Exit FALSE # ← OUTPUT "Enter the name to be found " INPUT Target REPEAT ``` ______ `THEN` ``` OUTPUT Target, " does not exist" Exit TRUE # ← ENDIF Mid Lower + (Upper – Lower + 1) DIV 2 # ← IF Names[Mid] < Target THEN ``` `Lower` # ← ``` ENDIF IF Names[Mid] > Target THEN ``` ``` ENDIF ``` ______ `THEN` ``` OUTPUT Target, " was found at location ", Mid Exit TRUE # ← ENDIF ``` <span class="part-marks">6 marks</span> ### (b) Big O notation is used to classify efficiency of algorithms. The Big O notation for time complexity in a binary search is O(log n). #### (i) State the Big O notation for time complexity of a linear search. <span class="part-marks">1 mark</span> #### (ii) Describe the meaning of O(log n) as it applies to a binary search algorithm. <span class="part-marks">2 marks</span>
Show mark scheme

11(a) [3 marks]

One mark for each correct OOP term definition: • Instance – an occurrence of an object // a specific object based on the class // an instantiation of a class. • Inheritance – the capability of defining a new class of objects that has all the attributes and methods from a parent class. • Polymorphism – allows the same method to take on different behaviours depending on which class is instantiated // methods can be redefined for derived classes.

11(b) [5 marks]

One mark for each point: • and Car ENDCLASS • Four declarations – must use the identifiers used in the assignments • Constructor header – must use CarBodyType • Two assignments – must use CarMake • Constructor identifier for the car model and the identifier in the Model assignment statement match CLASS Car PRIVATE Make : STRING PRIVATE Model : STRING PRIVATE BodyType : STRING PRIVATE Fuel : STRING PRIVATE NumberBuilt : INTEGER PUBLIC PROCEDURE NEW (CarMake : STRING, CarModel : STRING , CarBodyType : STRING )  Make CarMake  Model CarModel  BodyType CarBodyType  Fuel ""  NumberBuilt 0 ENDPROCEDURE getFuel() getNumberBuilt() ENDCLASS

Q8
May/Jun 2022 Paper 1 v2

Describe one application of Artificial Intelligence (AI). 3 marks 2 marks

Describe **one** application of Artificial Intelligence (AI). <span class="part-marks">3 marks</span> <span class="part-marks">2 marks</span>
Show mark scheme

8 1 mark for identification of an application Max 2 marks for relevant description e.g.

 Police identifying wanted people  Uses image recognition  ... to identify features/characteristics/items in an image  Natural language interfaces  Use speech recognition to identify words that are spoken  ... and adapts to learn regional accents  Self-driving cars  Detects its position on the road and within the traffic  Follows a route // Collision avoidance // Self-parking etc.  Spoken Interfaces  Use natural language processing  ... to take a sentence and work out its meaning  Game playing  Models characters in a computer game  ... to allow computer characters to react according to the player's movements

Q9
Oct/Nov 2021 Paper 3 v1

(a) The diagram shown represents an artificial neural network.

Layer 1 Hidden Layer 2

Layer 3

(i) State the reason for having multiple hidden layers in an artificial neural network. 1 mark

(ii) Explain how artificial neural networks enable machine learning. 4 marks

(b) Find the shortest path between the Home and School nodes using the A* algorithm. 5 marks 3 marks

Show your working in the table provided.

The first two rows in the table have been completed.

Node Cost from Home node (g) Heuristic (h) Total (f = g + h)
Home 0 14 14
A 1 10 11

Final path 10 (a) State three essential features of recursion .

1

2

3

(b) Explain the reasons why a stack is a suitable Abstract Data Type (ADT) to implement recursion. 3 marks

(c) Identify two ADTs other than a stack. 2 marks

1

2

(d) The function StackFull() checks whether a stack is full. 5 marks

The function uses the variable TopOfStack to represent the pointer to the most recent position used on the stack, and the variable Max to represent the maximum size of the stack. Assume TopOfStack and Max are global variables.

    FUNCTION StackFull() RETURNS BOOLEAN
    IF TopOfStack = Max THEN
    RETURN TRUE
    ELSE
    RETURN FALSE
    ENDIF
    ENDFUNCTION

An algorithm AddInteger is required to add a new integer data element to a stack.

The stack is implemented as an array ArrayStack .

The function AddInteger() calls StackFull() and returns an appropriate message.

Complete the pseudocode for the function AddInteger() .

    FUNCTION AddInteger(NewInteger : INTEGER) RETURNS STRING
     ENDFUNCTION
### (a) The diagram shown represents an artificial neural network. ![](../images/w21_31_q9_fig1.png) Layer 1 Hidden Layer 2 Layer 3 #### (i) State the reason for having multiple hidden layers in an artificial neural network. <span class="part-marks">1 mark</span> #### (ii) Explain how artificial neural networks enable machine learning. <span class="part-marks">4 marks</span> ### (b) Find the shortest path between the Home and School nodes using the A* algorithm. <span class="part-marks">5 marks</span> <span class="part-marks">3 marks</span> Show your working in the table provided. The first two rows in the table have been completed. ![](../images/w21_31_q9_fig2.png) |Node|Cost from Home node (g)|Heuristic (h)|Total (f = g + h)| |---|---|---|---| |Home|0|14|14| |A|1|10|11| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| **Final path** **10 (a)** State **three** essential features of **recursion** . 1 2 3 ### (b) Explain the reasons why a stack is a suitable Abstract Data Type (ADT) to implement recursion. <span class="part-marks">3 marks</span> ### (c) Identify **two** ADTs other than a stack. <span class="part-marks">2 marks</span> 1 2 ### (d) The function `StackFull()` checks whether a stack is full. <span class="part-marks">5 marks</span> The function uses the variable `TopOfStack` to represent the pointer to the most recent position used on the stack, and the variable `Max` to represent the maximum size of the stack. Assume `TopOfStack` and `Max` are global variables. ``` FUNCTION StackFull() RETURNS BOOLEAN IF TopOfStack = Max THEN RETURN TRUE ELSE RETURN FALSE ENDIF ENDFUNCTION ``` An algorithm `AddInteger` is required to add a new integer data element to a stack. The stack is implemented as an array `ArrayStack` . The function `AddInteger()` calls `StackFull()` and returns an appropriate message. Complete the pseudocode for the function `AddInteger()` . ``` FUNCTION AddInteger(NewInteger : INTEGER) RETURNS STRING ``` ``` ENDFUNCTION ```
Show mark scheme

9(a)(i) [1 mark]

One mark for correct statement (Max 1) Enables deep learning to take place • Where the problem you are trying to solve has a higher level of • complexity it requires more layers to solve To enable the neural network to learn and make decisions on its own • To improve the accuracy of the result. •

9(a)(ii) [4 marks]

One mark for each correct marking point (Max 4) Artificial neural networks are intended to replicate the way human brains • work Weights / values are assigned for each connection between nodes • The data are input at the input layer and are passed into the system • They are analysed at each subsequent (hidden) layer where • characteristics are extracted / outputs are calculated … this process of training / learning is repeated many times to achieve • optimum outputs // reinforcement learning takes place Decisions can be made without being specifically programmed • The deep learning net will have created complex feature detectors • The output layer provides the results • Back propagation (of errors) will be used to correct any errors that have • been made.

9(b) [5 marks]

One mark for each correct calculation as follows (Max 4) Node B (from Home) (Line 3 in table) • Node C (from Home) (Line 4 in table) • Node B and Node E (from A) (Lines 5 and 6 in table) • Node F and Node School (from E) (Lines 7 and 8 in table) • Node School (from F) (Line 9 in table) • One mark for correct path (Max 1) : Home School     • Node Cost from Home Heuristic Total Node (g) (h) (f = g + h) 1 Home 0 14 14 2 A 1 10 11 3 B 5 7 12 4 C 4 9 13 5 B 1 + 3 = 4 7 11 6 E 1 + 6 = 7 3 10 7 F 7 + 1 = 8 3 11 8 School 7 + 5 = 12 0 12 9 School 8 + 3 = 11 0 11 Final Path Home School    

Q9
Oct/Nov 2021 Paper 3 v2

(a) The diagram shown represents an artificial neural network.

Layer 1 Hidden Layer 2

Layer 3

(i) State the reason for having multiple hidden layers in an artificial neural network. 1 mark

(ii) Explain how artificial neural networks enable machine learning. 4 marks

(b) Find the shortest path between the Home and School nodes using the A* algorithm. 5 marks 3 marks

Show your working in the table provided.

The first two rows in the table have been completed.

Node Cost from Home node (g) Heuristic (h) Total (f = g + h)
Home 0 14 14
A 1 10 11

Final path 10 (a) State three essential features of recursion .

1

2

3

(b) Explain the reasons why a stack is a suitable Abstract Data Type (ADT) to implement recursion. 3 marks

(c) Identify two ADTs other than a stack. 2 marks

1

2

(d) The function StackFull() checks whether a stack is full. 5 marks

The function uses the variable TopOfStack to represent the pointer to the most recent position used on the stack, and the variable Max to represent the maximum size of the stack. Assume TopOfStack and Max are global variables.

    FUNCTION StackFull() RETURNS BOOLEAN
    IF TopOfStack = Max THEN
    RETURN TRUE
    ELSE
    RETURN FALSE
    ENDIF
    ENDFUNCTION

An algorithm AddInteger is required to add a new integer data element to a stack.

The stack is implemented as an array ArrayStack .

The function AddInteger() calls StackFull() and returns an appropriate message.

Complete the pseudocode for the function AddInteger() .

    FUNCTION AddInteger(NewInteger : INTEGER) RETURNS STRING
     ENDFUNCTION
### (a) The diagram shown represents an artificial neural network. ![](../images/w21_32_q9_fig1.png) Layer 1 Hidden Layer 2 Layer 3 #### (i) State the reason for having multiple hidden layers in an artificial neural network. <span class="part-marks">1 mark</span> #### (ii) Explain how artificial neural networks enable machine learning. <span class="part-marks">4 marks</span> ### (b) Find the shortest path between the Home and School nodes using the A* algorithm. <span class="part-marks">5 marks</span> <span class="part-marks">3 marks</span> Show your working in the table provided. The first two rows in the table have been completed. ![](../images/w21_32_q9_fig2.png) |Node|Cost from Home node (g)|Heuristic (h)|Total (f = g + h)| |---|---|---|---| |Home|0|14|14| |A|1|10|11| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| **Final path** **10 (a)** State **three** essential features of **recursion** . 1 2 3 ### (b) Explain the reasons why a stack is a suitable Abstract Data Type (ADT) to implement recursion. <span class="part-marks">3 marks</span> ### (c) Identify **two** ADTs other than a stack. <span class="part-marks">2 marks</span> 1 2 ### (d) The function `StackFull()` checks whether a stack is full. <span class="part-marks">5 marks</span> The function uses the variable `TopOfStack` to represent the pointer to the most recent position used on the stack, and the variable `Max` to represent the maximum size of the stack. Assume `TopOfStack` and `Max` are global variables. ``` FUNCTION StackFull() RETURNS BOOLEAN IF TopOfStack = Max THEN RETURN TRUE ELSE RETURN FALSE ENDIF ENDFUNCTION ``` An algorithm `AddInteger` is required to add a new integer data element to a stack. The stack is implemented as an array `ArrayStack` . The function `AddInteger()` calls `StackFull()` and returns an appropriate message. Complete the pseudocode for the function `AddInteger()` . ``` FUNCTION AddInteger(NewInteger : INTEGER) RETURNS STRING ``` ``` ENDFUNCTION ```
Show mark scheme

9(a)(i) [1 mark]

One mark for correct statement (Max 1) Enables deep learning to take place • Where the problem you are trying to solve has a higher level of • complexity it requires more layers to solve To enable the neural network to learn and make decisions on its own • To improve the accuracy of the result. •

9(a)(ii) [4 marks]

One mark for each correct marking point (Max 4) Artificial neural networks are intended to replicate the way human brains • work Weights / values are assigned for each connection between nodes • The data are input at the input layer and are passed into the system • They are analysed at each subsequent (hidden) layer where • characteristics are extracted / outputs are calculated … this process of training / learning is repeated many times to achieve • optimum outputs // reinforcement learning takes place Decisions can be made without being specifically programmed • The deep learning net will have created complex feature detectors • The output layer provides the results • Back propagation (of errors) will be used to correct any errors that have • been made.

9(b) [5 marks]

One mark for each correct calculation as follows (Max 4) Node B (from Home) (Line 3 in table) • Node C (from Home) (Line 4 in table) • Node B and Node E (from A) (Lines 5 and 6 in table) • Node F and Node School (from E) (Lines 7 and 8 in table) • Node School (from F) (Line 9 in table) • One mark for correct path (Max 1) : Home School     • Node Cost from Home Heuristic Total Node (g) (h) (f = g + h) 1 Home 0 14 14 2 A 1 10 11 3 B 5 7 12 4 C 4 9 13 5 B 1 + 3 = 4 7 11 6 E 1 + 6 = 7 3 10 7 F 7 + 1 = 8 3 11 8 School 7 + 5 = 12 0 12 9 School 8 + 3 = 11 0 11 Final Path Home School    

Q9
May/Jun 2021 Paper 3 v1

(a) Describe what is meant by an imperative (procedural) programming language. 2 marks 2 marks

(b) Describe what is meant by a declarative programming language. 4 marks

(c) Identify the programming paradigm for eac ch of these program code examples.
Program code example Programming paradigm
male(john).
female(ethel).
parent(john, ethel).

FOR Counter = 1 TO 20
X = X * Counter
NEXT Counter

Start: LDD Counter
INC ACC
STO Counter

public class Vehicle
{
private speed;
public Vehicle()
{
speed = 0;
}
}
### (a) Describe what is meant by **an imperative (procedural)** programming language. <span class="part-marks">2 marks</span> <span class="part-marks">2 marks</span> ### (b) Describe what is meant by **a declarative** programming language. <span class="part-marks">4 marks</span> |(c) Identify the programming paradigm for eac|ch of these program code examples.| |---|---| |**Program code example**|**Programming paradigm**| |`male(john).`<br>`female(ethel).`<br>`parent(john, ethel).`|| |<br>`FOR Counter = 1 TO 20`<br>` X = X * Counter`<br>`NEXT Counter`|| |<br>`Start: LDD Counter`<br>` INC ACC`<br>` STO Counter`|| |<br>`public class Vehicle`<br>`{`<br>` private speed;`<br>` public Vehicle()`<br>` {`<br>` speed = 0;`<br>` }`<br>`}`||
Show mark scheme

9(a)

One mark for each correct marking point (Max 2) Imperative languages use variables • … which are changed using (assignment) statements • … they rely on a method of repetition / iteration. • The statements provide a sequence of commands for the computer to • perform … in the order written / given • … each line of code changes something in the program run. •

9(b) [2 marks]

One mark for each correct marking point (Max 2) Instructs a program on what needs to be done instead of how to do it • ... using facts and rules • … using queries to satisfy goals. • Can be logical or functional • Logical - states a program as a set of logical relations • Functional – constructed by applying functions to arguments / uses a • mathematical style

9(c) [4 marks]

One mark for each correct programming paradigm (Max 4) Program code example Programming paradigm male(john). Declarative female(ethel). parent(john, ethel). FOR Counter = 1 TO 20 Procedural / imperative X = X * Counter NEXT Counter Start: LDD Counter Low-level / assembly INC ACC STO Counter public class Vehicle { private speed; public Vehicle() Object oriented / (OOP) { speed = 0; } }

Q9
May/Jun 2021 Paper 3 v2

(a) Describe what is meant by an imperative (procedural) programming language. 2 marks 2 marks

(b) Describe what is meant by a declarative programming language. 4 marks

(c) Identify the programming paradigm for eac ch of these program code examples.
Program code example Programming paradigm
male(john).
female(ethel).
parent(john, ethel).

FOR Counter = 1 TO 20
X = X * Counter
NEXT Counter

Start: LDD Counter
INC ACC
STO Counter

public class Vehicle
{
private speed;
public Vehicle()
{
speed = 0;
}
}
### (a) Describe what is meant by **an imperative (procedural)** programming language. <span class="part-marks">2 marks</span> <span class="part-marks">2 marks</span> ### (b) Describe what is meant by **a declarative** programming language. <span class="part-marks">4 marks</span> |(c) Identify the programming paradigm for eac|ch of these program code examples.| |---|---| |**Program code example**|**Programming paradigm**| |`male(john).`<br>`female(ethel).`<br>`parent(john, ethel).`|| |<br>`FOR Counter = 1 TO 20`<br>` X = X * Counter`<br>`NEXT Counter`|| |<br>`Start: LDD Counter`<br>` INC ACC`<br>` STO Counter`|| |<br>`public class Vehicle`<br>`{`<br>` private speed;`<br>` public Vehicle()`<br>` {`<br>` speed = 0;`<br>` }`<br>`}`||
Show mark scheme

9(a)

One mark for each correct marking point (Max 2) Imperative languages use variables • … which are changed using (assignment) statements • … they rely on a method of repetition / iteration. • The statements provide a sequence of commands for the computer to • perform … in the order written / given • … each line of code changes something in the program run. •

9(b) [2 marks]

One mark for each correct marking point (Max 2) Instructs a program on what needs to be done instead of how to do it • ... using facts and rules • … using queries to satisfy goals. • Can be logical or functional • Logical - states a program as a set of logical relations • Functional – constructed by applying functions to arguments / uses a • mathematical style

9(c) [4 marks]

One mark for each correct programming paradigm (Max 4) Program code example Programming paradigm male(john). Declarative female(ethel). parent(john, ethel). FOR Counter = 1 TO 20 Procedural / imperative X = X * Counter NEXT Counter Start: LDD Counter Low-level / assembly INC ACC STO Counter public class Vehicle { private speed; public Vehicle() Object oriented / (OOP) { speed = 0; } }

Q9
May/Jun 2021 Paper 3 v3

(a) Describe what is meant by an imperative (procedural) programming language. 2 marks 2 marks

(b) Describe what is meant by a declarative programming language. 4 marks

(c) Identify the programming paradigm for eac ch of these program code examples.
Program code example Programming paradigm
male(john).
female(ethel).
parent(john, ethel).

FOR Counter = 1 TO 20
X = X * Counter
NEXT Counter

Start: LDD Counter
INC ACC
STO Counter

public class Vehicle
{
private speed;
public Vehicle()
{
speed = 0;
}
}
### (a) Describe what is meant by **an imperative (procedural)** programming language. <span class="part-marks">2 marks</span> <span class="part-marks">2 marks</span> ### (b) Describe what is meant by **a declarative** programming language. <span class="part-marks">4 marks</span> |(c) Identify the programming paradigm for eac|ch of these program code examples.| |---|---| |**Program code example**|**Programming paradigm**| |`male(john).`<br>`female(ethel).`<br>`parent(john, ethel).`|| |<br>`FOR Counter = 1 TO 20`<br>` X = X * Counter`<br>`NEXT Counter`|| |<br>`Start: LDD Counter`<br>` INC ACC`<br>` STO Counter`|| |<br>`public class Vehicle`<br>`{`<br>` private speed;`<br>` public Vehicle()`<br>` {`<br>` speed = 0;`<br>` }`<br>`}`||
Show mark scheme

9(a)

One mark for each correct marking point (Max 2) Imperative languages use variables • … which are changed using (assignment) statements • … they rely on a method of repetition / iteration. • The statements provide a sequence of commands for the computer to • perform … in the order written / given • … each line of code changes something in the program run. •

9(b) [2 marks]

One mark for each correct marking point (Max 2) Instructs a program on what needs to be done instead of how to do it • ... using facts and rules • … using queries to satisfy goals. • Can be logical or functional • Logical - states a program as a set of logical relations • Functional – constructed by applying functions to arguments / uses a • mathematical style

9(c) [4 marks]

One mark for each correct programming paradigm (Max 4) Program code example Programming paradigm male(john). Declarative female(ethel). parent(john, ethel). FOR Counter = 1 TO 20 Procedural / imperative X = X * Counter NEXT Counter Start: LDD Counter Low-level / assembly INC ACC STO Counter public class Vehicle { private speed; public Vehicle() Object oriented / (OOP) { speed = 0; } }