Section 12: Algorithms Flashcards
Define what an algorithm with constant complexity is.
An algorithm with constant complexity is one that always executes in the same time regardless of the size of the data set.
What is the big O notation for constant complexity?
Constant complexity:
O(1)
Define what an algorithm with logarithmic complexity is.
An algorithm with logarithmic complexity is an algorithm that halves the data set in each pass (opposite to exponential).
What is the big O notation for logarithmic complexity?
Logarithmic complexity:
O(log n)
Define what an algorithm with linear complexity is.
An algorithm with linear complexity is an algorithm thats performance is proportional to the size of the data set and declines as the data set grows.
What is the big O notation for linear complexity?
Linear complexity:
O(n)
Define what an algorithm with polynomial complexity is.
An algorithm with polynomial complexity is an algorithm thats performance is proportional to the square of the size of the data set. It becomes significantly more inefficient as the size of the data set grows.
What is the big O notation for polynomial complexity?
Polynomial complexity:
O(n^k) where k is the number of nested loops.
Define what an algorithm with exponential complexity is.
An algorithm with exponential complexity is an algorithm thats time complexity doubles with each addition to the data set (opposite to logarithmic).
What is the big O notation for exponential complexity?
Exponential complexity:
O(2^n)
What is the worst case time complexity for a linear search?
Linear search big O:
O(n)
What is the worst case time complexity for a binary search?
Binary search big O:
O(log n)
What is the worst case time complexity for traversing a binary tree?
Binary tree traversal big O:
O(n)
What is the worst case time complexity for a bubble sort?
Bubble sort big O:
O(n^2)
What is the worst case time complexity for an insertion sort?
Insertion sort big O:
O(n^2)