2.1 Algorithms Flashcards
Define abstraction
Removing unnecessary details
Define decomposition
Breaking complex problems into smaller parts
Easier to work with
Solve at the same time
Shown in structure diagram
Define algorithmic thinking
Identifying individual steps needs to reach the solution
Allows to automate solutions
What are the two searching algorithms
Binary
Linear
Describe how to do a binary search
Look at middle number
Compare to target number and discard half of list to big/ to small to the target
Process starts again until target is found
Pros of binary search
Efficient and quicker than linear
Fewer comparisons
Cons of binary search
List must be in order
What is linear search
Each item in the list is checked one at a time from left to right until target number is found
Pros of linear search
Doesn’t need to be in order
Simple to run and create
Cons of linear search
Very slow
Inefficient and requires lots of comparisons
What flowchart diagram is this
Start/end
What flowchart diagram is this
Decision
What flowchart diagram is this
Input or output
What flowchart symbol is this
Process
What flowchart symbol is this
Sub program
What is a syntax error
Error in spelling or grammar used when coding which causes an error message
What is a logic error
Mistake in the programs code which results in unexpected behaviour although the code is correct
What is a trace table
Table that follows the values of variables to check for accuracy
What is iteration
A FOR loop - loop number is known as
A WHILE loop - loop number is unknown
What is selection
IF
ELSE
ELIF
What are the three sorting algorithms
Bubble
Insertion
Merge
What is bubble sort
Compares two numbers
Numbers are swapped if left is greater
Process repeated until list is in order
Goes through list an extra time to check its in order
Pros and cons of bubble sort
Pros - simple to create/run
Cons - slow,inefficient and requires lots of comparisons
What is insertion sort
Puts first number in sorted list
Compares rest of numbers in un sorted list with sorted list
Inserts it into the correct place
Pros and cons of insertions sort
Pros- faster and fewer comparisons
Cons-more complicated than bubble
What is merge sort
Splits into individual lists
Single numbers into groups of two sorting as they merge
Groups of 2 into groups of 4
Repeat until it’s one list
Pros and cons of merge sort
Pros - Efficient for long lists
Cons - inefficient for small lists or lists that are slightly out of order