computer paper 2

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

1/306

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 8:04 PM on 6/13/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

307 Terms

1
New cards

what is time complexity

how much time it requires to solve a particular problem

2
New cards

how is decomposition used in a game

breaks the problem down into its component parts. game can be divided into subprograms. subprograms can then be programmed as subroutines

3
New cards

how would pipelining be used in a game

the results from one subroutine will feet into the next subroutine

4
New cards

bubble sort pros

it is intuitive - easier to write

5
New cards

cons of global variables in a procedure

past values of the variable will remain

6
New cards

purpose of big o notaiton

to evaluate the tie complexity of an algorithm, and how the time taken increases with anincrease in the data set

7
New cards

What is tim complexty measured using

big-O notation

8
New cards

pros of data mining

  • can look for links between a customer’s purchases

  • can provide recommendations for future pruchases

  • boost profits

  • ensure demand is met

  • improve quantity of stock needed

9
New cards

What is big-O notation

Shows the effectivness of the algorithm by showing the upper limit for the amount of time taken relative to the number of data elements given as an input

10
New cards

Why do we find the time complexity of algorithms

Allos you to predict the amount of time it takes an algorithm to finish given the bumber of data elements

11
New cards

How to reduce time complexity

Reduce the number of embedded loops or reduce the number of items you have to complete operations on

12
New cards

What is 0(1)

constant time complexity - the amount of time taken to complete the algorithm is independent from the number of elements inputted

13
New cards

quikc way of recognising Ono (1)

loops

14
New cards

0(1) graph

horizontal line

15
New cards

what is 0(n)

linear time complexity - the amount of time taken to complete the algorithm is directly proportional to the number of elements inputted

16
New cards

quick way of recognising linear time complexity

one loop repeating n times

17
New cards

example of 0(n)

linear search

18
New cards

linear search algorithm

def linearsearch(list, item):

index = -1

i = 0

found = False

while i < len(list) and found == False:

if list[i] == item:

index = i

found = True

i = i + 1

return index

19
New cards

0(n) graph

straight line through origin

20
New cards

what is 0(nn)

Polynomial time complexity - the amount of time taken to complete the algorithm is directly proportional to the elements inputted to the power of n

21
New cards

Example of an algorithm with a polynomial time complexity

Nested for loops - the power in the polynimial is the same as the number of nested for loops. eg bubble sort is O(n²)

22
New cards

bubble sort algorithm

def bubblesort (array):

for i in range (0,len (array)):
for j in range (0, len(array)-1):
if array[j] > array[j+1]:
temp = array[j]
array[j] = array [j+1]
array[j+1] = temp
return array

23
New cards

What is 0(2n)

Exponential time complexity - the amount of time taken to complete an algorithm will double with every additional item e

24
New cards

example of an algorithm with an exponential time complexity

recursion

25
New cards

What is 0 (log n)

logarithmic time complexity - the time taken to complete the algorithm will increase at a smaller rate as the number of elements inputted

26
New cards

Example of algorithms with a logarithmic time complexity

divide and conquer algorithms - eg binary search as the number of items to search through gets halved each time

27
New cards

why is big-O notation important

it is a way of comparing algorithms so that the most efficient one can be chosen. A bad time complexity can make a problem involving vast amounts of data infeasible to solve

28
New cards

how does a linear search work

Starts with first item. This is compared to the item to be found. If equal then report found. If not equal then move to next item.
Repeat for all items, until found or end of list reached, which returns false.

29
New cards

when to use linear search

small losts or unordered lists

30
New cards

worst case time complexty of a linear search

O(n)

31
New cards

average time complexity of linear search

O(n)

32
New cards

best case time complexiy of linear search

O(1)

33
New cards

space complexity of linear seacrh

O(1)

34
New cards

how does binary search work

midpoint is calculated by adding upper and lower bound and dividing by two and rounding. If the item at the middle of the array is equal to the item to be found, set found to true. If the item to be found is less than the middle item, change the upper bound to be the midpoint - 1. if the item to be found is greater than the middle item, set the lower bound as the midpoint + 1. Repeat this porocess until the lower bound is greater than the upper bound. Rturn the found flag.

35
New cards

worst case time complexty for binary search array

O(log n )

36
New cards

average time complexity of binary search

O(log n )

37
New cards

best case time complexity of binary seacrh array

O(1)

38
New cards

space complexity of binary search

O(1)

39
New cards

worst case time complexity for binary search on a binary tree

O(n)

40
New cards

What is the worst to best time complexity

exponential , polynomial, linear, logarithmic, constant

41
New cards

What is spacce time complexity

The amount of storage an algorithm takes

42
New cards

How to reduce space complexity

Ensure you perform all changes on the original pieces of data because extra data is stored whenever a copy is made, which uses more storage so is more expensive

43
New cards

What is an algorithm

A series of steps that completes a task

44
New cards

What are the objectives of designing an algorithm

To get the best time and space complexity. There is no priority, it depends on the situation

45
New cards

When would you prioritise time complexity

If you have a lot of data that needs to be processed quickly

46
New cards

When would you prioritise space complexity

If you have a lot of processing power, time complexity isnt that important so you would prioritise space to make sure lots of data isnt wasted often

47
New cards

when to not use binary search

unordered list

48
New cards

how does a bubble sort work

Starting at the beginning of the list. Items are swapped with their
neighbour if they are out of order. Each pair of neighbours is checked in order. When a swap is made a flag is set. If at the end of the list the flag has been set, the flag is unset and the
algorithm starts from the beginning of the list again. When the algorithm gets to the end
of the list and the flag is unset, the list is sorted and the algorithm finishes

49
New cards

how to improve bubble sort

Checking one less item per iteration or alternating sorting directions

50
New cards

worst case time complexit of a bubble sort

O(n2)

51
New cards

average case time complexoty of bubble sort

O(n2)

52
New cards

best case time complexity of bubble sort

O(n)

53
New cards

space complexity of bubble sort

O(1)

54
New cards

how does insertion sort work

Breaks list into a sorted list (initially empty) and an unsorted list. One item taken from the unsorted list at a time and inseted into the sorted list in the correct place

55
New cards

worst case time complecity for insertion sort

O(n²)

56
New cards

Average case time complexity for insertion sort

O(n²)

57
New cards

best case time complexity for insertion sort

O(n)

58
New cards

space complexity of insertion

O(1)

59
New cards

Why is bubble sort inefficient

requires significantly more swaps than other algorithms, meaning it takes up more CPU cycles to solve the same problem

60
New cards

how does a merge sort work

divides the unsorted list into 2 until eachsublists contains one element. Repeatedly merge sublists by comparing the first item of both lists and selecting the smaller item and writing it into a new list. Repeat until all sorted sublists are recombined into a single list

61
New cards

worst case time complexity of merge sort

O(nlog n)

62
New cards

average case time complexity for merge sort

O(nlog n)

63
New cards

best case time complexity for merge sort

O(n log n )

64
New cards

space complexity for merge sort

O(n)

65
New cards

How does quick sort work

Use divide and conquer. One item in the list is made the pivot. All other items are compared to the pivot and are moved to the left of the pivot if it is smaller than it or to the right of the pivot if it is larger than it. This algorithm recursively repeats for the sublists to the left and right of the pivot (by choosing a pivot in each sublist) until there is only one element either side of the pivot.

66
New cards

worst case time complexity for quick sort

O(n²)

67
New cards

average case time complexity for quick sort

O(n log n)

68
New cards

best case time complexity for quick sort

O( n log n)

69
New cards

space complexity for quick sort

O(log n)

70
New cards

Why might a bubble or insertion sort be better than a quick or merge sort

easier to implement the algorithm and quicker on nearly sorted lists

71
New cards

what is meant by logarithmic growth

as the size of the array increases, the rate at which the number of checks needed increases more slowly

72
New cards

when is quick and merge sort better than insertion and bubble sort

larger data sets

73
New cards

which is faster insertion or bubble sort

insertion

74
New cards

why do bubble sort and insertion sort have space complexity of O(1)

They are inplace (all sorting takes place within the data itself)

75
New cards

why do bubble sort and insertion sort have time complexity of O(n²)

Nested loop

76
New cards

When is a depth first traversal used

job scheduling, where some jobs have to be completed before others can begin

77
New cards

what is breadth first traversal used for

finding the shortest path between two points ; eg facebook uses this to find all friends of a given person

78
New cards

why are trees traversed

to get the information stored in them

79
New cards

what is an intractable problem

one that cannot be solved efficiently - eg in polynomial time

80
New cards

what is an insoluble problem

one that has no solution at all other than heuristics

81
New cards

describe breadth firsth traversal

visits the first node and all conncting nodes. Then visits connecting nodes to these

82
New cards

describe depth first traversal

goes to the left node, this becomes a nw tree. Continues going left until it reaches a leaf. It then returns this value and then goes right and repeats from start.

83
New cards

Evaluate the use of breadth first vs depth first traversals

Breadth is more efficient when the data to be searched is closer to the root, whereas depth first is more effiient when data is further down. Breadth also generally has a better time complexity. Depth can be written recusively to aid understanding but in large trees, it may never return a value. Also depth memory requirement is linear.

84
New cards

why are values stored in an arrya instead of separate variables when sorted

so all values can be indexed in one array

85
New cards

compare bubble sort, insertion sort and merge sort

The best case time complexity for bubble sort and insertion sort is O(n), which is shorter than the best case for merge sort O(n log n). however, merge sort best worst and av time complexity is the same, wherease bubble and insertion average and worse cases are O(n²). Bubble and insertion have constant memory but merge uses more memory as new lists are needed.

86
New cards

describe how a leaf node is deleted from a binary search tree

traverse tree until required node is found. Set parent node to the leaf node to null

87
New cards

Describe how a ninary tree is searched for a value

  1. If root is equal , return found

  2. If value < root, tke left subtree. if value> root, take right subtree

  3. repeat process for subtree

  4. until value is found or no more branches can be travelled

88
New cards

Explain how backtracking is used in depth first traversal

When a leaf node is reached, the traversal backtracks to the leaf’s parent node

89
New cards

Describe how to add a new item to the end of a linked list

insert new item at the index of the next free pointer. Traverse the list to find the last item and update this pointer to be the index of the next free pointer. Update the next free pointer to the index the new item is pointing to Set the pointer of the new item to null.

90
New cards

Explain exponential

The rate of increase is at a rate of k^n as n increases . This makes it unmanageable for large data sets

91
New cards

explain constant

does not change

92
New cards

what is a jeuristic

a rule of thumb that estimates the distance from each node to the destination node

93
New cards

what loop could be used instead of while for a binary search algorthm

do until

94
New cards

Explain why quicksort is regarded as a divide and conquer lgorithm

decomposes the data set into smaller subsets which are then sorted before the subsets are recombined to provide a solution

95
New cards

describe how a binary search tree can be searched

if root node is equal to the item to be found, report found. If the item is smaller, take the left subtree. If the item is larger, take the right subtree. Repeat process for the subtree until item is found or no more branches to be travelled

96
New cards

evaluate the use of heuristics for a computer game

  • Heuristics are rules of thumb used to find a ‘good enough solution’ to a problem.

  • They are used to reduce the time taken to solve a problem.

  • They work by adding a weight to a node. For example, it is used in the A star algorithm to estimate the shortest route between two nodes.

  • They reduce the time complexity as every possibility within the game does not need to be examined.

  • They are used in AI when the exact steps cannot be pre-programmed and decisions need to be made.

  • Heuristics are more appropriate with complex time-critical tasks and some aspects of the game may require faster searching.

  • Heuristics are more appropriate with large-scale tasks and the game could be large-scale, and AI algorithms may need to be shortened.

  • Games are not life critical so a good answer is likelt enough and a perfect answer is not necessarily required.

  • Avoids programs running indefinitely- in a computer game there could be too many

  • In a gane, characters will have a certain number of paths they can follow which involve different routes so heuristics will be used to determine what path the character should take o get to one specific destination

97
New cards

Cons of heuristics

  • However, they require skill to be implemented effectively - ie determining the hueristics of every node

  • Due to time-saving, they are not always accurate and the solution eg the shortest path may not be the most efficient

  • With a small number of paths, the time difference may not be noticeable

98
New cards

Why does thinking procedurally make writing a program easier

breaks down problem into smaller parts which are easier to understand and easier to design

99
New cards

First stage of thinking proceduraly

Problem decomposition - large, complex problem is continually broken down into smaller subproblems. Problem becomes more feasible to manage and can be divided between a group of people according to the skill stes of individuals,

100
New cards

How are problems decomposed

top-down design. Breaks down problems into levels. Higher levels provide an overview of a problem while lower levels specify in detail the components of this problem