4.4.4.2 Maths for understanding Big-0 notation and 4.4.4.3 Order of complexity Flashcards
What is Big-O notation?
it is a way of defining how efficient an algorithm is by how “fast” it will run. You determine the algorithm’s notation by the worst case scenario run time.
see http://bigocheatsheet.com/
What is constant time?
O(1)
using a constant-size lookup table
One of the most ideal complexities
What is logarithmic time?
O(logn)
Finding an item in a sorted array with a binary search or a balanced search tree
One of the most ideal complexities
What is linear time?
O(n)
Finding an item in an unsorted list
What algorithms are O(nlogn)?
heapsort or merge sort
What is quadratic time?
Multiplying two n-digit numbers by a simple algorithm; bubble sort (worst case
quicksort (worst case),
selection sort or insertion sort
What is exponential time?
O(2^n) Finding the (exact) solution to the travelling salesman problem
What is factorial time?
O(n!)
Solving the travelling salesman problem via brute-force search;