cramcards mod5 Flashcards
decomposition
breaking down into smaller problems and solving each individually
abstraction
picking out important bits
algorhythmic thinking
steps it takes to solve a problem can be used to solve another one in future
flowchart boxes
start/stop - rounded corners
input/output - paralellogram
processes - rectangles
decision - diamond
binary search
1) find middle item
2) if its the item you’re looking for stop
3) if not, compare item to the middle term. if above, eliminate below vice versa
4) get middle of lower half
5) repeat
can only look in ordered list
linear search
1) look at first item
2) if its correct stop
3) if not look at next item
4) repeat
can look in unordered lists
bubble sort
1) look at first two items
2) if in right order move on, if in wrong order swap them
3) move on and repeat process
4) keep doing this until all are in correct place
merge sort
1) split list in half (second sub starts middle term)
2) repeat until all sublists are 1
3) merge sublists so each has twice as many items
4) repeat until all sublists together
bubble sort pros cons
simple
efficient for checking if in right order
doesn’t use much memory
inefficient way to sort
not cope with large list
merge sort pros cons
efficient
consistent running time
slower for small lists
goes through process even if sorted
uses more memory
insertion sort
1) look at second item
2) compare to all numbers before
3) if not in right place insert into right place
4) repeat until done