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
What is a Unit in programming?
The smallest component of a program that can be tested.
What is Recursion?
It means breaking a problem down into subsets of the same problem.
What are the cons of Recursion?
Don’t scale up, slow, and more abstract.
What are the pros of Recursion?
Fast and easy to code; practical for free traversal and binary search.
What is Linear Search?
A search algorithm that iterates through each item in a list one at a time comparing it to a key.
When is Linear Search used?
Used to sort lists and arrays; the only option for unsorted data.
What is Binary Search?
A divide and conquer method that compares the value to half the list and keeps halving until found.
What are the characteristics of Binary Search?
Quick; data must be sorted.
What is Selection Sort?
It finds the smallest item in a list and places it in the first position, then repeats for the next smallest.
What is Insertion Sort?
It iterates through the sorted items in a list to determine the correct location for each new item.
What is Bubble Sort?
It iterates through a list examining pairs of items at a time.
What is Quicksort?
A sorting algorithm that can be implemented recursively, repeated on subsets until a stopping point is reached.
Who developed Quicksort and when?
Developed by Tony Hoare in 1959.
What is Unit Testing?
Unit tests use test cases.
What are the advantages of Unit Testing?
Fast, allows bugs to be easily identified, makes it easy for others to check, provides documentation, and provides confidence that the code should work.