Revision Session Programming Flashcards
Abstraction
Removing detail
Decomposition
Breaking a problem into chunks
Algorithmic thinking
Thinking a structured way, using sequence, selection and iteration
The sun icon doesn’t look like the actual sun
Decomposition use
Break a range of temperatures into hot mild cold
Structure diagram
Linear search algorithm
Look at each item work from beginning to end - slow process
IF it is the value you are looking for
Stop
ELSE move to the next item
REPEAT UNTIL. No more items
Binary search
Split in middle
Take the middle value
IF it is the value you are looking for stop
Bubble sort
Take 2 elements from the list
Swap them depending on order
Repeat until sorted
Linear search for 5 in the list
9,4,8,5,3,6,7
9,4,8,5 (stop)
Binary search for 8 in list
1,2,4,5,7,8
Look at 4 (middle rounded down) Discard lower half (1,2,4) Look at 7 (middle of upper half 5,7,8) Discard lower half (5,7) Look at 8
Why could the binary search not be completed on the first list
(Linear search for 5 in list 9,4,8,5,3,6,7)
Not in order
Explain which search generally finds a value faster?
Binary search
Discards lots of information on each loop / iteration
Bubble sort on list 6,7,10,5,3,9,10
6,7,5,3,9,10,10 (first pass of swaps)
6,5,3,7,9,10,10 (second pass)
5,3,6,7,9,10,10 (third)
3,5,6,7,9,10,10 (final)