Algorithms (Paper 2) Flashcards

(26 cards)

1
Q

what are the three main principles of computational thinking

A

abstraction
decomposition
algorithmic thinking

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is abstraction

A

the process of removing unnecessary details of a problem to focus on the important features to implement in a solution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

implementations of abstraction

A

computer games
users don’t need to know the complex algorithms used to control the NPCs. it is only important to the user they recognise the environment and when they perform an action, they see a response

train maps
travellers don’t need to know the geographical layout of the routes, only that getting on at stop A will eventually transport you to stop B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is decomposition

A

the process of breaking down a large problem into a set of smaller problems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

benefits of decomposition

A

smaller problems are easier to solve
each smaller problem can be solved independently of others
smaller problems can be tested independently
smaller problems can be combined to produce a solution to the full problem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

describe computer games as an example of decomposition

A

modern computer games are decomposed to break down the complexity of the problem into more manageable ‘chunks’. for example:
levels - levels can be designed/created independently of other levels
characters - the mechanics of characters in the game can be designed and created by a separate team
landscape - the art team can work on the visual aspects of the game without needing to understand how the game is programmed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is algorithmic thinking

A

the process of creating step-by-step instructions in order to produce a solution to a problem
algorithmic thinking requires the use of abstraction and decomposition to identify each individual step
once each step has been identified, a precise set of rules (algorithm) can be created and the problem will be solved

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is a searching algorithm

A

precise step-by-step instructions that a computer can follow to efficiently locate specific data in massive data sets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

conditions for a binary search to be performed on a set of data

A

the data must be in order.
it can be performed on datasets containing numbers or words.
searching for a word instead of a number is the same process, except comparisons are made based on position in the alphabet instead of numerical size

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

how to perform a binary search

A

-identify middle value
-compare to value you are looking for
-if it is the value you are looking for, stop
-else if it is bigger then the one you are looking for, create a new list with the values on the left of the middle value
-if it is smaller than the one you are looking for, create a new list with the values on the right of the middle value
-repeat with the new list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is a linear search

A

starts with the first value in a data set and checks every value one at time until all values have been checked

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

advantages for binary searches

A

-fast for large datasets
-efficient for repeated searches

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

disadvantages of binary search

A

-dataset must be in order
-more complex to implement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

advantages for linear search

A

-works on unsorted datasets
-faster on very small datasets
-simple to understand and implement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

disadvantages for linear search

A

-slow for large datasets
-inefficient, starts at the beginning each time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what are the three common sorting algorithms

A
  • Bubble sort
  • Merge sort
  • Insertion sort
17
Q

how to perform a bubble sort

A

-compare the first two values in the dataset
-if they are in the wrong order, swap them
-compare the next two values
-repeat step 2 and 3 until you reach the end of the dataset (pass 1)
-if you have made any swaps, repeat from the start
-else if you have not made only swaps, stop - the list is in the correct order

18
Q

what strategy does a merge sort use

A

‘divide and conquer’ strategy of dividing a dataset into smaller sub-datasets and merging them back together in the correct order

19
Q

how to perform a merge sort

A
  1. divide the dataset into individual datasets by repeatedly splitting the data set in half
  2. merge pairs of sub-datasets together by comparing the first value in each dataset
  3. repeat step 2 until all sub-datasets are merged together into one dataset
20
Q

how to perform an insertion sort

A
  1. take the first value in the dataset, this is now the sorted list
  2. look at the next value in the dataset and compare it to the first value. if it is smaller, insert it into the correct position to the left
  3. else, keep it in the same position
  4. repeat steps 2 and 3 until all values in the dataset have been compared, the list should now be in order
21
Q

what shape is a terminator symbol (start/stop)

A

rectangle with rounded edges

22
Q

what shape are input/output symbols

23
Q

what shape are process symbols

24
Q

what shape are decision symbols

25
what is a syntax error
an error that breaks the grammatical rules of a programming language and stops it from running
26
what is a logic error
where incorrect code is used that causes the program to run, but produces an incorrect output or result