Final Flashcards
(27 cards)
bubble sort
considers objects in pairs, swaps them if they’re in wrong order, largest unsorted item bubbles to top
pros of bubble sort
simple to write, little memory is used, easy to understand
cons of bubble sort
takes a very long time with large amounts of data, goes through list several times making it slow
merge sort
divide and conquer, cuts list down into sublists
pros of merge sort
faster for larger lists, has consistent running time
cons of merge sort
uses more memory to store sublists, goes through entire process even if list is sorted
selection sort
repeatedly finds minimum element from unsorted part and puts it at beginning
pros of selection sort
performs well on small lists, does not require additional storage
cons of selection sort
not efficient for large lists
insertion sort
repeatedly scans lists of items, inserting the item into its correct position
pros of insertion sort
simple, good for small lists, requires minimal storage
cons of insertion sort
does not work well w/large lists, does not perform as well as other algorithms
quick sort
divide and conquer, puts list into sublists
pros of quick sort
efficient in dealing w/large lists, no additional storage necessary, sorts lists of any size easily
cons of quick sort
its worst performance is similar to that of bubble sort, insertion, or selection
counting sort
counts the number of objects having distinct key values, calculates position of each object in the output sequence
pros of counting sort
easy to code, performs generally faster than other algorithms
cons of counting sort
does not work on decimal values, ineffcient if range is very large
radix sort
creates/distributes elements into buckets according to their radix
pros of radix sort
fast when keys are short, stable bc it maintains relative order of elements w/equal values
cons of radix sort
less flexible, takes up more space, slow if operations are inefficient
binary search
search begins at middle of list, finds item or eliminates half of unexamined items, repeats until item is found, finding number in 7 tries example
sequential search
starts at beginning of list searches the entire list until the item is found
what shape starts and ends a flow chart?
oval