algorithims Flashcards
what is decomposition
the process of breaking down a problem into smaller more managable parts which are easier to solve
what is abstraction
ignoring or filering out the unnecisary deatils that arent important
algorithms
method of planning to show how you can solve a problem that you have
what does the cylinder mean
start or end
what is process
square
what is input or output
paralellogram
what is decision
diamond
what are the 2 searching algorithms
binary and linear
what is linear search
It just works it way through the list one at a time until it finds the one it is looking for.
what is binary search
finds the middle value
Compare to the value you are looking for.
IF it is the value you are looking for.
Celebrate, and stop.
ELSEIF it is larger than the one you are looking for.
Take the values to the left of the middle value.
IF it is smaller than the one you are looking for.
Take the values to the right of the middle value.
Repeat with the new list.
what are the 3 sorts
bubble
merge
insertion
what is bubble sort
Look at the first two items in the list
If they’re in the right order, do not swap, if they’re not then swap them Move onto the next pair of items (2nd and 3rd) and repeat step 2 Repeat step 3 until you get to the end of the list – this is called one pass. Repeat steps 1-4 until there are no swaps in a pass (this means it is in order)
when is a pass over
when you get to the end of the list
benefits of bubble sort
It is a simple algorithm that can be easily implemented
It is an efficient way to check if a list is already in order Doesn't use much memory as all the sorting is done on the original list
drawbacks of bubble sort
inefficient
doesnt cope well with large lists
what is insertion sort
Start with the second item in the list, the items to the left of it are known as the sorted list.
Compare it to the items before it (in this case just the first item) and insert the value into the right place. Repeat step 2 for the third, fourth etc items until the last number in the list has been inserted into the correct place.
benefits of insertion sorts
It copes very well with small lists
Doesn’t require much memory
benefits of merge sort
good for larger lists
consistant running time
what are the 3 programming constructs
sequencing
selection
iteration
what is iteration
this is when the program repeats a set of instructions inside a loop until a condition is met.
what is selection
this is where the path through a program can be decided by looking at a condition
what is sequencing
when a program follows a list of instructions in order (top to bottom)
how to retrieve elements from an array
you use the array name followed by the element that it is in.