computer science paper 2

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/180

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

181 Terms

1
New cards

abstraction

when you ignore unnecessary information and focus only on the important facts

2
New cards

why is abstraction used

it simplifies a problem to make it less complex, which makes it more straightforward to understand the problem and create a solution

3
New cards

what is decomposition

when you break a problem down into smaller tasks so that it is easier to solve, each individual problem can be separately tested and solved

4
New cards

what does decomposition allow

enables different people to work on the different parts of a larger problem that can later be recombined to produce a full solution

5
New cards

algorithmic thinking

final stage as logical steps are followed to solve the problem

6
New cards

what happens in algorithmic thinking

the problem is broke down using decomposition into smaller problems, the relevant data structures are considered using abstraction

7
New cards

what is an algorithm

set of instructions presented in a logical sequence

8
New cards

why do programs create algorithm designs

as a method of planning a program before writing any code to help them consider the potential problems of the program and make it easier to start creating source code

9
New cards

flowcharts

can be used to visually represent an algorithm

10
New cards
term image

start/stop terminator

11
New cards
term image

operation (process)

12
New cards
term image

decision (if statement)

13
New cards
term image

input/output

14
New cards
term image

subroutine

15
New cards
term image

direction of low

16
New cards

structure diagrams

display the organisation of a problem in a visual format, showing the subsections to a problem and how they link to other sections

17
New cards

trace tables

used to track the value of a variable as a program is run

18
New cards

how can trace tables be used

can be used to manually track the values in order to investigate why the program isn’t working as intended

19
New cards

what do rows and columns represent in trace tables

each row in the trace table represents another iteration, each column stores the value of a variable as it changes

20
New cards

linear search

the most simple search algorithm, each data is searched in order from the first value to the last as if they were all laid out in a line

21
New cards

sequence of linear search

the list does not have to be in any order before it is searched (aka sequential search as the list is searched in a sequence from the start to the end

22
New cards

linear search for large list

for large lists this search is not very efficient

23
New cards

key features of a linear search (loops)

used to check the first value in a list and increment by 1, checking each value for a match to the target

24
New cards

key features of a linear search (values not included)

reaching the last element of the list without finding a match means the value is not included

25
New cards

binary search

more more efficient searching algorithm as it generally searches through fewer data and is often much quicker - especially for large data sets

26
New cards

what happens in a binary search

the middle point of the data is selected with each iteration and compared to the value being searched for, when the midpoint matches the target value it has been found as the search can stop

27
New cards

what happens before using a binary search

the list of data must already be sorted

28
New cards

what is a prerequisite

a condition that must be satisfied before an algorithm will work correctly

29
New cards

key features of a binary search (calculations)

a midpoint, lowpoint and highpoint are calculated

30
New cards

key features of a binary search (while loop)

used to repeatedly compare the midpoint to a target value

31
New cards

key features of a binary search (upper/lower half)

the upper half or lower half of the data is ignored if the midpoint does not equal the target

32
New cards

merge sort

divides a list into half, again and again until each data item is separated, and then combined in the same way as they were divided but now in the correct order

33
New cards

what happens when the individual lists are all merged together in merge sort

then the data is in order and the algorithm will end

34
New cards

key features of a merge sort (recursive algorithm)

this algorithm calls itself from within the subroutine

35
New cards

key features of a merge sort (sublists)

it continually splits sublists into a left side and a right side until each sublist has a length of 1

36
New cards

bubble sort

data elements are swapped if they are not in the correct order, the algorithm will only stop when a complete iteration through the data is completed with no swaps made

37
New cards

bubble sorts with large sets of data

a bubble sort is not suitable for large sets of data

38
New cards

key features of a bubble sort (outer while loop)

uses an outer while loop (condition controlled) to check no swaps have been made

39
New cards

key features of a bubble sort (inner for loop)

uses an inner for lop (count controlled) to repeat through the length of the data set

40
New cards

key features of a bubble sort (flag)

uses a flag (a Boolean value) to track if a swap has been made and uses a temporary value to help correctly swap elements

41
New cards

insertion sort

the list is logically split into sorted values on the left and unsorted values on the right

42
New cards

how does insertion sort work (1)

starting from the left, values from the unsorted part are checked and inserted at the correct position in the sorted part

43
New cards

how does insertion sort work (2)

this continues through all elements of the list until the last item is reached, and sorted

44
New cards

adv/dis adv insertion sorts

insertion sorts are efficient for small data sets but would be slow to sort large sets compared to alternatives such as a merge sort

45
New cards

key features of a insertion sort (outer for loop)

uses an outer for loop (count controlled) to iterate through each value in the list

46
New cards

key features of a insertion sort (inner while loop)

uses an inner while loop (condition controlled) to find the current values correct position in the sorted part of the list

47
New cards

key features of a insertion sort (movement)

an insertion sort moves ‘backwards’ to find the correct position of each value, by decreasing the index within the while loop

48
New cards
<p>programming constructs: sequence</p>

programming constructs: sequence

structuring code into a logical, sequential order

49
New cards
<p>programming constructions: selection</p>

programming constructions: selection

decision making using if statements

50
New cards
<p>programming construction: iteration</p>

programming construction: iteration

repeating code using for or while loops

51
New cards

variables

used to store data in programs, they can be changed as the program runs

52
New cards

two parts of a variable

the data value and the identifier

53
New cards

efficient programs utilisation of variables

an efficient program will use variables with sensible identifiers that immediately state their purpose in the program

54
New cards

why use variable names like ‘TotalNum’ and ‘Profit’ rather than ‘num1’ and ‘num2’

means that other programmers will be able to work out the purpose of the code without the need for extensive comments

55
New cards

local variables

declared within a specific subroutine and can only be used within that subroutine

56
New cards

global variables

can be used at any point within the whole program

57
New cards

local variable advantages (saves memory)

only uses memory when that local variable is needed, global variables use memory whether they are used or not

58
New cards

local variable advantages (easier to debug)

easier to debug local variables as they can only be changed within one subroutine

59
New cards

local variable advantages (reusability)

you can reuse subroutines with local variables in other programs

60
New cards

global variable advantages (versatility)

variables can be used anywhere in the whole program and in multiple subroutines

61
New cards

global variable advantages (maintenance)

makes maintenance easier as they are only declared once

62
New cards

global variable advantages (constants)

can be used for constants - values that remain the same

63
New cards

what is a constant

data that does not change in value as the program is run - it is fixed and remains the same

64
New cards
<p>comparison operators</p>

comparison operators

used to compare two data values

65
New cards

arithmetic operators

used to mathematically manipulate values

66
New cards

arithmetic operators: modulo division

reveals the remainder from the last whole number

67
New cards

arithmetic operators: integer division

reveals the whole number of times a number can be divided into another number

68
New cards

logical operators

typically use TRUE or FALSE values which is known as Boolean

69
New cards

data types: character

a single character such as a letter, number or punctuation symbol

70
New cards

data types: string

a sequence of characters, including letters, numbers and punctuation

71
New cards

data types: integer

whole number

72
New cards

data types: real

decimal number

73
New cards

data type: Boolean

an answer that only has two possible value

74
New cards

telephone numbers

are always stored as a string, not an integer

75
New cards

casting

converting the value of a variable from open data type into another

76
New cards

what is a subprogram

large programs are often broken down into smaller subprograms also called subroutines, each focuses on a specific function of the code helping to decompose a complex problem into more manageable chunks

77
New cards

define subprogram (python)

def command

78
New cards

calling subprograms

running a line of code that includes the name of a subprogram will call it, when called, the program will run the subprogram code before returning back to the lien that called it, subprograms are only run when called, so depending on decision made a program may end without calling every subroutine

79
New cards

parameters

value that is passed into a subprogram when it is called, allowing the value to be used within the subprogram, a subprogram may not use a parameter

any parameter must be identified when the subprogram is defined

80
New cards

return (1)

the return command will send a value back to the line the subprogram was called on, allowing it to be used there

81
New cards
<p>return (2) example</p>

return (2) example

e.g the ‘quad’ subprogram returns the value of the result variable back to the main program, allowing it to be printed

82
New cards

return (3)

a subprogram will end either by reaching the last line of code within it, or when it reaches a return command

83
New cards

functions

subprograms that return a value are called functions

84
New cards
<p>why is the subprogram called in the main program in the example</p>

why is the subprogram called in the main program in the example

the subprogram is called in the main program, multiplies the number passed in as a parameter by 4 and returns a value back to the main program to be printed

85
New cards

types of subprograms: functions

returns the value, using the return command, which allows the value to be used in the line of code the function was called in

the divide function below returns the value of the variable total to the main program to be printed

86
New cards

types of subprograms: procedure

does not return a value

87
New cards

advantages of using subprograms (breaking down)

break a complex program down into smaller parts, making it easier to design and test, each subroutine can be tested separately and abstraction can be used to simplify a complicated problem

88
New cards

advantages of using subprograms (reusability)

using subprograms allow code to be easily reused in other programs, as it has already been written, making it quicker to develop new programs or build on existing work

89
New cards

advantages of using subprograms (repetition)

using subprograms avoid code repetition as they can be called as many times as necessary, making programs shorter and quicker to develop, making them easier to maintain and debug

90
New cards

advantages of using subprograms (work)

work can easily be split up between team members to work on different subprograms at the same time

91
New cards

array

static data structure that can hold a fixed number of data elements, each data element must be iof the same data type

92
New cards

how are the elements in an array identified

by a number that indicates their position in the array, known as the index, the first element in an array always has an index of 0

93
New cards

difference and similarity in array and two dimensional array

the data in a two dimensional array must still all be of the same data type, but can have multiple rows and columns

94
New cards

records

can store data of different data types, each record is made up of information about open person or thing and each piece of information is called a field

95
New cards

key field

records should have a key field: this is unique data that identifies each record

96
New cards

key field (2) example

student ID is a good key field for a record on students as no two students can have the same student ID

97
New cards

2D array and records

a 2D array may be used to represent databse tables of records and fields

98
New cards

SQL

language that can be used to search for data in a database

99
New cards

format of an SQL statement

SELECT field1, field2, field3…

FROM table

WHERE criteria

100
New cards

factors to consider when creating a secure program: anticipating misuse

planning ahead to take steps against potential misuse e.g the app X prevents the same tweet sent twice in a row as it might be spam