algorithms Flashcards
understand and explain algorithms
à sequence of steps that can be followed to complete à task
explain decomposition
breaking a problem into a number of sub problems to accomplish à task
abstraction
process of removing unnecessary detail from à problem
how are some algorithms more efficient the others
time it takes to run a particular algorithm
linear search algorithms
simpler then binary but less efficient
run time is similar
checks each item of the list to find the correct one
binary search algorithm
finding the middle item in à less and seeing whether the item is greater or less then the middle number
the takes out the lower/upper half of the list
bubble sort algorithm
used to sort an unordered list of items
check each pair of numbers to see if in right position otherwise swap them around
1 +2, 2+3, 3+4
bubble sort advantages and disadvantages
advantages
simple algorithm
efficient way to check if a list is in order
does use memory ask much
disadvantages
inefficient way to sort a list
slow for a large list of items
merge sort algorithm
sorts list apart and then merged them together
split list in half until only one item in all list
merge pairs of sub lists and sort items into right order
merge sort pros and cons
pros
more efficient to sort for larger list
similar running time is
consistent running time
cons
if the list is already sorted it goes through the whole process again
uses more memory