Algorithms Flashcards
What are the three types of computational thinking?
abstraction - focusing on just the important details of the problem
decomposition - breaking a problem down into smaller parts
algorithmic thinking - creating a step by step solution to the problem
Linear search
checks each item in the list one by one until it finds what it is looking for
adv - doesn’t need to be ordered
disadv - not efficient, takes time
Binary search
find middle item. if it is the item you are looking for then stop. otherwise compare to the item you are looking for and then half the half you have left over. Then repeat until you are finished.
adv - More efficient
disadv - list has to be ordered
Bubble sort
Checks the first two items in a list, swaps them if they are in the wrong order and then moves onto the next two items and repeats the process. Once it has passed through the list once it goes through again until none of the items need swapping.
+ Simple.
– Takes a long time
Merge sort
Finds the middle item (n+1)/2 and splits the list in half. Repeats this step until the list is split into individual items (sub-lists). It them merges (joins) the sublists in pairs. Each time the sublists are paired they are sorted into the correct order.
+ Efficient
– Slow
Insertion sort
Looks at the second item in a list and compares it to the items that are in front of it, then inserts it into the right place. It then moves to the next item in the list and repeats these steps.
+ Quick for sorting small lists
– slow withlong lists
Flowchart symbols
Oval - start/stop
Diamond - decision
Rectangle - action
input, process, output
input - what info is entered
process - the thing that happens to the input
output - the result of the process
structure diagram
shows how a problem is broken down
common errors
syntax - mistakes using language e.g.comma or quotation mark
logic - mistake in the programs source code.
runtime - error whilst executing the program
trace tables and their uses
used to determine outputs from a program as it runs. They enable a programmer to find errors in their programs.