Chapter 9: More Python Flashcards
Bubble Sort
Iterates through a list examining pairs of items at a time
Selection Sort
It works by finding the smallest item in a list and then placing it in the first position. It then finds the next smallest item and places it in second position.
Insertion Sort
It works by iterating through the sorted items in a list to determine the correct location at which to insert each new item.
What is the advantages of functions?
Hide the complexity of the code
Easy to understand
Recursion
breaking a problem down into subsets of the same problem
Cons of recursion
doesnt scale up like iteration
iterative solutions are mostly faster
more abstract
harder to understand than iterative solutions
Pros of recursion
fast and easy to code
practical for tree traversal and binary search
Advantages of Linear Search
It is quick and more efficient for smaller and unsorted data
Binary Search
It is referred to as the divide and conquer algorithm as when using binary search we compare the value to half the list to see if it is there and we keep halving and halving (comparing as well) until we find it.
Linear search
It is a search algorithm that iterates through each item in a list one at a time comparing it to a key
(Used to sort list and arrays
Only option for unsorted data)
Quick sort
Implement recursively.
The sorting algorithm is recursively repeated on subsets of the same problem until a specific stopping point is reached
Unit
smallest component of a program that can be tested
Advantages of Unit Testing
Fast
Allows bugs to be easily identified
Makes easy for others to check
Provides documentation