Complete paper 2 computer science deck

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/193

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 8:02 AM on 5/17/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

194 Terms

1
New cards

What is an AND gate?

Outputs 1 only when both inputs are 1 — if either input is 0 the output is 0

2
New cards

What is an OR gate?

Outputs 1 when at least one input is 1 — only outputs 0 when both inputs are 0

3
New cards

What is a NOT gate?

Inverts the input — if input is 1 output is 0 — if input is 0 output is 1 — also called a NOT gate or inverter

4
New cards

Complete the truth table for AND

A=0 B=0 → 0. A=0 B=1 → 0. A=1 B=0 → 0. A=1 B=1 → 1

5
New cards

Complete the truth table for OR

A=0 B=0 → 0. A=0 B=1 → 1. A=1 B=0 → 1. A=1 B=1 → 1

6
New cards

Complete the truth table for NOT

A=0 → 1. A=1 → 0

7
New cards

What is the output of A AND B when A=1 and B=0?

0 — because both inputs must be 1 for AND to output 1

8
New cards

What is the output of A OR B when A=0 and B=1?

1 — because at least one input is 1

9
New cards

What is the output of NOT A when A=1?

0 — NOT inverts the input

10
New cards

Complete the truth table for A AND (NOT B)

A=0 B=0 → NOT B=1 → 0 AND 1 = 0. A=0 B=1 → NOT B=0 → 0 AND 0 = 0. A=1 B=0 → NOT B=1 → 1 AND 1 = 1. A=1 B=1 → NOT B=0 → 1 AND 0 = 0

11
New cards

Complete the truth table for (A OR B) AND (NOT A)

A=0 B=0 → 0 AND 1 = 0. A=0 B=1 → 1 AND 1 = 1. A=1 B=0 → 1 AND 0 = 0. A=1 B=1 → 1 AND 0 = 0

12
New cards

How do you work out the output of a logic diagram with multiple gates?

Work from left to right — calculate the output of each gate in order — use the outputs of earlier gates as inputs to later gates — build up a truth table column by column

13
New cards

What is a high-level programming language?

A language that is closer to human language — easy to read and write — needs to be translated into machine code — eg Python Java C# — more portable and easier to debug

14
New cards

What is a low-level programming language?

A language closer to machine code — harder to read and write — closely tied to the hardware — includes assembly language and machine code — faster and more efficient but harder to program

15
New cards

What are the differences between high-level and low-level languages?

High-level — easy to read — portable — needs translating — slower execution. Low-level — hard to read — hardware specific — faster execution — gives more direct control over hardware

16
New cards

What is a translator?

Software that converts code written in one language into machine code that the computer can execute — needed because computers only understand binary machine code

17
New cards

What is a compiler?

A translator that converts the entire high-level source code into machine code in one go — produces a standalone executable file — the original source code is not needed to run the program

18
New cards

What is an interpreter?

A translator that converts and executes high-level source code one line at a time — does not produce a standalone file — source code is needed every time the program runs

19
New cards

What are the advantages of a compiler?

Faster execution once compiled — source code is hidden in the executable — program can run without the original source code or translator

20
New cards

What are the disadvantages of a compiler?

Errors are only reported after the whole program is compiled — harder to debug — compilation takes time — compiled code may not be portable across different hardware

21
New cards

What are the advantages of an interpreter?

Easier to debug — errors are reported line by line as they occur — useful during development — more portable across platforms

22
New cards

What are the disadvantages of an interpreter?

Slower execution because translation happens every time the program runs — source code must be present to run the program — less secure as source code is exposed

23
New cards

What is an IDE?

Integrated Development Environment — software that provides tools to help programmers write test and debug programs — all tools available in one place

24
New cards

What editor tools does an IDE provide?

A text editor with features like syntax highlighting — auto-completion — auto-indentation — bracket matching — makes writing code faster and reduces errors

25
New cards

What are error diagnostics in an IDE?

Tools that identify and highlight errors in code — syntax errors are underlined or highlighted as you type — error messages explain what went wrong and where

26
New cards

What is a run-time environment in an IDE?

Allows the programmer to run and test their program directly within the IDE — no need for separate software — can observe the program executing

27
New cards

What translator tools does an IDE provide?

Built-in compiler or interpreter — allows the programmer to translate and run their code without leaving the IDE — may allow switching between interpreter and compiler mode

28
New cards

How does an IDE help a programmer produce better code?

Syntax highlighting makes code readable — auto-completion speeds up writing — error diagnostics catch mistakes early — run-time environment allows immediate testing — all tools in one place reduces context switching

29
New cards

What is defensive design?

Writing programs that anticipate and handle misuse — ensuring the program behaves correctly even when given unexpected or invalid inputs — making programs reliable and secure

30
New cards

What is input validation?

Checking that data entered by a user meets specific criteria before it is processed — rejects invalid data and asks the user to re-enter — prevents errors and crashes

31
New cards

Write OCR ERL code that validates a user enters a number between 1 and 10

num = int(input("Enter a number 1-10")). while num < 1 OR num > 10. print("Invalid — try again"). num = int(input("Enter a number 1-10")). endwhile

32
New cards

What is authentication?

Confirming the identity of a user before allowing access — typically using a username and password — prevents unauthorised access

33
New cards

Write OCR ERL code for a simple username and password check

username = input("Username"). password = input("Password"). if username == "admin" AND password == "pass123" then. print("Access granted"). else. print("Access denied"). endif

34
New cards

What are naming conventions and why are they important?

Using clear descriptive names for variables and subprograms — eg totalScore instead of x — makes code easier to read and maintain — allows others to understand the code

35
New cards

What is indentation and why is it important?

Adding spaces or tabs to show the structure of code — makes it clear which statements are inside loops or selection statements — improves readability and maintainability

36
New cards

What is commenting and why is it important?

Adding notes to code using // in OCR ERL — explains what sections of code do — does not affect execution — helps others understand and maintain the code

37
New cards

What is the purpose of using subprograms in terms of maintainability?

Breaks code into smaller named sections — each section can be developed and tested independently — reduces repetition — makes code easier to read update and debug

38
New cards

What is the purpose of testing?

To ensure a program works correctly — identifies and fixes errors before the program is used — checks the program behaves as expected for all possible inputs

39
New cards

What is iterative testing?

Testing modules of a program during development — testing each section as it is written — allows errors to be found and fixed early before they affect other parts

40
New cards

What is final or terminal testing?

Testing the complete finished program at the end of development — checks the whole system works together correctly — checks it meets the original requirements

41
New cards

What is a syntax error and give an example?

An error that breaks the grammatical rules of the programming language — prevents the program from running — eg missing closing bracket — misspelled keyword — missing quotation mark

42
New cards

What is a logic error and give an example?

An error where the program runs but produces incorrect output — eg using > instead of >= causing a boundary to be missed — or an infinite loop due to the wrong condition

43
New cards

What is normal test data?

Data that is valid and within the expected range — should be accepted and processed correctly by the program — eg entering 5 for an input expecting a number between 1 and 10

44
New cards

What is boundary test data?

Data that is on the very edge of what is valid — tests the limits of the program — eg entering exactly 1 or exactly 10 for a range of 1 to 10 — should be accepted

45
New cards

What is invalid test data?

Data of the correct data type but outside the acceptable range — should be rejected by the program — eg entering 0 or 11 for a range of 1 to 10

46
New cards

What is erroneous test data?

Data of the completely wrong data type — should be rejected — eg entering "hello" for a field expecting an integer — tests type checking and validation

47
New cards

Create a test plan for a program that accepts ages between 0 and 120

Normal — enter 25 — expected: accepted. Boundary — enter 0 — expected: accepted. Boundary — enter 120 — expected: accepted. Invalid — enter -1 — expected: rejected. Invalid — enter 121 — expected: rejected. Erroneous — enter "hello" — expected: rejected

48
New cards

What is abstraction?

Removing unnecessary detail from a problem to focus only on the important parts — simplifying complexity to make a problem easier to solve

49
New cards

What is decomposition?

Breaking a complex problem down into smaller more manageable sub-problems — each sub-problem can then be solved individually

50
New cards

What is algorithmic thinking?

Creating a step by step set of instructions to solve a problem — thinking logically about the sequence of steps needed

51
New cards

What is a structure diagram?

A diagram that shows the structure of a problem broken into subsections — shows how subsections link to each other — used in the design stage before coding

52
New cards

What is pseudocode?

An informal way of describing an algorithm using plain English and programming-like structure — not tied to any specific language — used to plan programs before writing real code

53
New cards

What are the flowchart symbols you need to know?

Oval/rounded rectangle — terminal (start/stop). Rectangle — process. Parallelogram — input/output. Diamond — decision. Rectangle with lines on sides — sub program. Arrow — flow of control

54
New cards

What is a trace table?

A table used to track the values of variables at each step of an algorithm — used to manually follow and check the logic of an algorithm — helps identify errors

55
New cards

What is a syntax error?

An error that breaks the grammatical rules of the programming language — prevents the program from being run or translated at all — eg missing bracket or misspelled keyword

56
New cards

What is a logic error?

An error where the program runs without crashing but produces unexpected or incorrect output — the code is syntactically correct but the logic is wrong — eg using < instead of <=

57
New cards

What is nesting?

Placing one selection or iteration construct inside another — eg an IF statement inside a FOR loop — or a WHILE loop inside an IF statement

58
New cards

LINEAR SEARCH

59
New cards

What is a linear search?

Checks each element of a list one by one from the start until the target is found or the end of the list is reached — works on both sorted and unsorted lists

60
New cards

What are the steps of a linear search?

Step 1 — start at the first element. Step 2 — check if the current element equals the target. Step 3 — if yes — return its position. Step 4 — if no — move to the next element. Step 5 — if end of list reached without finding target — return not found

61
New cards

What are the advantages of linear search?

Works on unsorted lists — simple to understand and implement — no pre-conditions required

62
New cards

What are the disadvantages of linear search?

Slow for large lists — must check every element in the worst case — inefficient compared to binary search on sorted data

63
New cards

Apply a linear search to find 15 in the list 8 3 15 22 7

Check 8 — not 15. Check 3 — not 15. Check 15 — found at position 3 (index 2)

64
New cards

Apply a linear search to find 10 in the list 5 12 3 9 6

Check 5 — no. Check 12 — no. Check 3 — no. Check 9 — no. Check 6 — no. End of list — 10 not found

65
New cards

BINARY SEARCH

66
New cards

What is a binary search?

Divides a sorted list in half — compares the middle element to the target — searches the left half if target is smaller — searches the right half if target is larger — repeats until found or not found

67
New cards

What are the steps of a binary search?

Step 1 — find the middle element of the list. Step 2 — if middle equals target — found. Step 3 — if target is less than middle — repeat on left half. Step 4 — if target is greater than middle — repeat on right half. Step 5 — if list is empty — not found

68
New cards

What is the key pre-condition for binary search?

The list must already be sorted — binary search will not work correctly on an unsorted list

69
New cards

What are the advantages of binary search?

Much faster than linear search for large sorted lists — eliminates half the remaining elements each time — very efficient

70
New cards

What are the disadvantages of binary search?

List must be sorted first — more complex to implement than linear search — sorting has its own cost

71
New cards

Apply a binary search to find 23 in the list 5 10 15 20 23 27 30

Middle = 20. 23 > 20 so search right half: 23 27 30. Middle = 27. 23 < 27 so search left: 23. Middle = 23 — found

72
New cards

Apply a binary search to find 7 in the list 2 4 7 9 11 13 15

Middle = 9. 7 < 9 so search left: 2 4 7. Middle = 4. 7 > 4 so search right: 7. Middle = 7 — found

73
New cards

Apply a binary search to find 6 in the list 1 3 5 7 9

Middle = 5. 6 > 5 so search right: 7 9. Middle = 7. 6 < 7 so search left: empty — 6 not found

74
New cards

BUBBLE SORT

75
New cards

What is a bubble sort?

Repeatedly compares adjacent pairs of elements — swaps them if they are in the wrong order — larger values bubble to the end — repeats passes until no swaps occur in a full pass

76
New cards

What are the steps of a bubble sort?

Step 1 — start at the beginning of the list. Step 2 — compare the first and second elements — if first is greater swap them. Step 3 — move to the next pair and repeat. Step 4 — continue to the end of the list — this completes one pass. Step 5 — repeat passes until a complete pass makes no swaps — list is sorted

77
New cards

How do you know when bubble sort is finished?

When a complete pass through the list produces no swaps — the list must be sorted

78
New cards

What are the advantages of bubble sort?

Simple to understand and implement — can detect an already sorted list quickly — uses very little additional memory

79
New cards

What are the disadvantages of bubble sort?

Very slow for large lists — requires many comparisons and swaps — inefficient compared to merge sort

80
New cards

Sort the list 5 3 8 1 using bubble sort — show all passes

Pass 1 — compare 5 and 3 swap → 3 5 8 1. Compare 5 and 8 no swap. Compare 8 and 1 swap → 3 5 1 8. Pass 2 — compare 3 and 5 no swap. Compare 5 and 1 swap → 3 1 5 8. Compare 5 and 8 no swap. Pass 3 — compare 3 and 1 swap → 1 3 5 8. Compare 3 and 5 no swap. Pass 4 — no swaps — sorted: 1 3 5 8

81
New cards

Sort the list 4 2 6 1 3 using bubble sort — show pass 1 only

Compare 4 and 2 — swap → 2 4 6 1 3. Compare 4 and 6 — no swap. Compare 6 and 1 — swap → 2 4 1 6 3. Compare 6 and 3 — swap → 2 4 1 3 6. End of pass 1

82
New cards

Sort the list 9 5 2 7 using bubble sort — show all passes

Pass 1 — 5 9 2 7 → 5 2 9 7 → 5 2 7 9. Pass 2 — 2 5 7 9 → 2 5 7 9. Pass 3 — no swaps — sorted: 2 5 7 9

83
New cards

MERGE SORT

84
New cards

What is a merge sort?

A divide and conquer algorithm — repeatedly splits the list in half until each section contains only one element — then merges pairs back together in sorted order — very efficient for large lists

85
New cards

What are the steps of a merge sort?

Step 1 — split the list into two halves. Step 2 — recursively split each half again until you have single elements. Step 3 — compare the first elements of two lists — take the smaller one. Step 4 — repeat until both lists are merged into one sorted list. Step 5 — continue merging up until the full list is sorted

86
New cards

How does the merging step work in merge sort?

Take two sorted lists — compare the first element of each — take the smaller and add it to the new sorted list — repeat until one list is empty — add remaining elements — result is one sorted merged list

87
New cards

What are the advantages of merge sort?

Very efficient for large lists — consistent performance — good for sorting linked lists — stable sort

88
New cards

What are the disadvantages of merge sort?

More complex to understand and implement — requires additional memory to store split lists during merging

89
New cards

Sort the list 4 2 7 1 using merge sort — show all steps

Split → 4 2 and 7 1. Split → 4 and 2 and 7 and 1. Merge 4 and 2 → 2 4. Merge 7 and 1 → 1 7. Merge 2 4 and 1 7 → compare 2 and 1 take 1 → compare 2 and 7 take 2 → compare 4 and 7 take 4 → take 7. Result: 1 2 4 7

90
New cards

Sort the list 8 3 5 1 using merge sort — show all steps

Split → 8 3 and 5 1. Split → 8 and 3 and 5 and 1. Merge 8 and 3 → 3 8. Merge 5 and 1 → 1 5. Merge 3 8 and 1 5 → compare 3 and 1 take 1 → compare 3 and 5 take 3 → compare 8 and 5 take 5 → take 8. Result: 1 3 5 8

91
New cards

Sort the list 6 4 2 8 3 1 using merge sort — show splitting stage only

Split → 6 4 2 and 8 3 1. Split → 6 4 and 2 and 8 3 and 1. Split → 6 and 4 and 2 and 8 and 3 and 1. Now merge back in pairs

92
New cards

INSERTION SORT

93
New cards

What is an insertion sort and how does it work?

Insertion sort builds a sorted list one element at a time — it takes each element from the unsorted part and inserts it into the correct position in the sorted part — like sorting playing cards in your hand — you pick up each card and slot it into the right place among the cards already sorted

94
New cards

What are the steps of an insertion sort — explained clearly?

Step 1 — the first element is already considered sorted. Step 2 — take the next element (the key). Step 3 — compare the key to each element in the sorted portion moving right to left. Step 4 — shift each sorted element one position to the right if it is greater than the key. Step 5 — insert the key into the gap created. Step 6 — repeat steps 2 to 5 for every remaining element

95
New cards

How does insertion sort slot an element into the right place?

It compares the element being inserted (the key) with the sorted elements to its left — each sorted element that is bigger than the key gets moved one place to the right — this creates a gap — the key is then placed in that gap — the sorted section grows by one each time

96
New cards

What are the advantages of insertion sort?

Simple to implement — very efficient for small or nearly sorted lists — builds sorted list in place using very little extra memory — can sort as data arrives

97
New cards

What are the disadvantages of insertion sort?

Slow for large unsorted lists — many comparisons and shifts needed in the worst case

98
New cards

Sort the list 5 3 8 1 using insertion sort — show every step clearly

Start — sorted section: 5. Unsorted: 3 8 1. Take key = 3. Compare 3 with 5 — 5 > 3 so shift 5 right. Insert 3 in gap. List now: 3 5 8 1. Take key = 8. Compare 8 with 5 — 5 < 8 so no shift. Insert 8 here. List now: 3 5 8 1. Take key = 1. Compare 1 with 8 — shift 8 right. Compare 1 with 5 — shift 5 right. Compare 1 with 3 — shift 3 right. Insert 1 at start. Sorted: 1 3 5 8

99
New cards

Sort the list 7 2 9 4 using insertion sort — show every step clearly

Start — sorted: 7. Take key = 2. 7 > 2 — shift 7 right. Insert 2. List: 2 7 9 4. Take key = 9. 7 < 9 — no shift. Insert 9. List: 2 7 9 4. Take key = 4. 9 > 4 — shift 9. 7 > 4 — shift 7. 2 < 4 — stop. Insert 4. Sorted: 2 4 7 9

100
New cards

Sort the list 6 1 4 2 using insertion sort — show every step clearly

Start — sorted: 6. Take key = 1. 6 > 1 — shift 6. Insert 1. List: 1 6 4 2. Take key = 4. 6 > 4 — shift 6. 1 < 4 — stop. Insert 4. List: 1 4 6 2. Take key = 2. 6 > 2 — shift 6. 4 > 2 — shift 4. 1 < 2 — stop. Insert 2. Sorted: 1 2 4 6