Unit 6 Flashcards

(40 cards)

1
Q

What is an algorithm

A

A set of instructions for solving a problem or completing a task

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

What is algorithmic thinking

A

A way of getting to the solution by identifying the steps required

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

What is abstraction

A

Removing unnecessary detail from a problem so you can focus on the essential

Relevant features are identified

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

What is decomposition and the advantages

A

Breaking down a problem into smaller sub problems and breaking them down further so they are manageable

A problem becomes easier to solve when it consists of a number of smaller tasks/modules and they may be reusable later in the problem/program saving development time

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

What is a binary search

A

The program analyses the middle item in the list
It works out if the item its looking for is above or below in the list (or that item is the item being looked for)
If above then the bottom half of the list is deselected
If below then top half of list is deselected
Repeat process until program has found the item

(If there is an even number in the list, ie: 2, the middle item would be the 1st out of the 2 items in the middle)
(only works in a sorted list)

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

What is the amount of searches necessary for the worst case scenario in a binary search

A

In a list of 2^n items the worst case scenario will be n + 1 number of times searched

If the n isn’t a whole number (ie: 1,000,000 items in the list), then you would need to find the closest integer n and add one (ie: 2^19 is less than 1M and 2^20 is over 1M so the worst case scenario would be 20 searches)

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

What is a linear search

A

When the program checks the list one by one to find the required item

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

What is a bubble sort and how many passes will the algorithn have

A

Starting from the first, each items is compared to the item next to it in the list. If the item to the right is smaller, they switch and if not they stay the same

The program moves onto the next 2 items in the list (including the 2nd item in the list from the 1st sorting). so if the previous sorting was the 1st and 2nd item, this would be the current 2nd item and 3rd item

The program sees if they are in the right order, switches if necessary and move onto the next (3rd and 4th). This continues until the program reaches the end of the list where one item will be successfully sorted (the last one)

Then the program goes again, starting from the bottom of the list and makes it way back up to the top. Now the 2nd to last item will be sorted.

The amount of passes an algorithm will have is the number of items in the list - 1

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

What is an insertion sort

A

the algorithm sorts data one item at a time: One item is taken and placed in the correct position and this repeats until there are no more unsorted items

The first item will remain unchanged as there is nothing to sort it against. The 2nd item will be sorted accordingly to the first. If it is larger then it will stay but if it is smaller it will go to the back. This repeats for all items and they get inserted to their correct position

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

What is merge sort

A

The list is broken down into smaller lists (divide by 2 or split) until there are many lists with just one item. Then the program takes 2 lists (presumable the ones next to each other) and merge them into one list by inserting them into the correct spot, making a sorted list of 2. This repeats for the whole list making many sorted lists of 2s.

To correctly sort 2 lists of 2s into one list of 4, let’s say the first item in list 1 is A then B. the 1st item in list 2 is C then D. We compare items C and A and decide which is smaller. If item C is smaller that goes in the new list. Then item A and D are compared. If item A is smaller that goes in the list and then item B and D are compared and sorted as so.

This process continues until there is just one list that is fully sorted

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

what is the order of how fast each sorting type is

A

1) Merge sort
2) Insertion sort
3) Bubble sort

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

What do the MOD and DIV operators do

A

MOD: Finds the remainder of a division

DIV: Integer division (only outputs the integer of the division)

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

What is a variable

A

A location in memory where you can temporarily store text or numbers

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

When you write a statement such as

total = mark1 + mark2

what variables are you assigning to a variable (total)

A

total
mark1
mark2

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

What do each flowchart operation mean

Start
End
Input
Output
Calculation/Assignment
Decision

A

Oval
Oval
paralellogram
paralellogram
Rectangle
Diamond with yes and no statements coming out the sides

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

What does the statement count = count + 1 mean

A

add 1 to the variable called count

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

What are the 3 programming constructs/structures

A

Sequence - regular statements that don’t affect which line the program will go to next (It will just go to the one under it)
Selection - if statements/elif statements or switch /case
iteration - while/for loops or do until loops

18
Q

Computational Thinking definition

A

the thought process involved in formulating problems so their solutions can be represented as computational steps and algorithms

19
Q

problem inputs definiton

A

The data or information provided to program an algorithm, complete a set task or solve a proble

20
Q

problem processes definition

A

steps or operations that a program or algorithm performs to solve a specific problem

21
Q

Problem output definition

A

The result or output delivered after an algorithm or program has finished processing given inputs.

22
Q

What are the 3 aspects of computational thinking

A

Algorithmic thinking
Abstraction
Decomposition

23
Q

What is an integer

A

A whole number (including negatives)

24
Q

Real

A

Number with a decimal point

25
Boolean
either true or false
26
Character
A single alphabetic or numeric character
27
string
a sequence with one or more characters
28
When a question asks to write in OCR Exam reference language, what style of code do you write in
You HAVE to write in pseudocode
29
What is pseudocode
A kind of structured English for describing algorithms it allows the programmer to focus on the logic of the algorithm without being distracted by the exact syntax of the programming language
30
In pseudocode how do you write if statements
Instead of using any colons, you get rid of them and replace them with "THEN"
31
How do you write for loops in pseudocode including steps
instead of using in range you write "for counter = 1 TO 7 STEP 2" (capitalisation isn't needed) ... NEXT counter "for counter from 10 to 0 step -2"
32
What does inclusive and exclusive mean in coding and which out of those 2 fit in python and pseudocode for loops
Inclusive: The last number in the for loops range is included and the for loop is repeated that many times (if the first one is 1) so if the loop is "for counter from 1 to 7" then the loop will repeat 7 times and counter will start and 1 and end at 7 Exculsive: The same except the last number isn't included so if the code is "for item in range(1,7):" then the loop will repeat 6 times and stop before the 7th iteration is done with
33
What do you need in while loops for pseudocode
endwhile at the end
34
What sets apart do until and while loops and their definitions
Use while loops when you want to execute a loop while a condition is true Use do until loops when you want to keep executing a loop until a certain condition is true do until: condition is checked at the end of the loop but while loops the condition is checked before the loops begins/at the start of the loop
35
How do we construct a simple flowchart while loop to check a passowrd
Start | | V IF STATEMENT (check if password is NOT the correct one) --> IF not then program goes to end (If so) | | V OUTPUT enter password | V INPUT password (loop back to if statement)
36
How do you write do until loops
do ... until... INDENTATION IS KEY
37
How do you draw a do until loop in flowchart
START | | V (loop you want to execute - may include more arrows) | | V IF STATEMENT (condition) - IF NO then go to top of the loop you want to execute (if yes go to end of program)
38
What is a trace table used for
A table used to find the purpose of an algorithm Used to determine the theoretical output from a program used to spot errors in the program
39
How do you draw a trace table
One column per variable in the order in which they appear (including booleans, such as n > 4) If a variable doesn't change you dont need to rewrite it in the same column
40
How do you construct a while loop in pseudocode:
while.... ... endwhile