lecture 4 (Unfinished) Flashcards
Why Sorting?
Sorting is one of the most common tasks in data analysis.
What is Selection sort?
The Selection Sort algorithm repeatedly finds the smallest element in the unsorted tail region of a list and moves it to the front
Big O -n^2
What is a Linear Search?
The list is traversed sequentially, and every element is checked#
List does NOT need to be sorted
Big-O: O(n)
What is a Binary Search?
A ‘divide and conquer algorithm
The list MUST be sorted
Big-O: O(log2(n))
How do you conduct a Binary Search?
1) find the middle element- if a match then were done
2) if the key is less the middle element the key must be in the first half (opposite if key bigger)
Binary Search vs Linear Search
Binary search algorithm is much faster, But it only works on sorted data.
Big-O of O(log2(n))
If Binary Search is used with selection sort then Linear Search is faster
What is Algorithm Complexity?
Algorithmic complexity tells us how slow or fast an algorithm performs
T(n) will be used to denote the time an algorithm takes to execute – time versus input size n
How do you perform asymptotic analysis?
We find the worst-case number of primitive operations executed as a function of the input size, T(n)
We express this function with Big-Oh notation