What is the Big O Notation?
A measure of the complexity of an algorithm.
State all the Big O Notations from worst to best in terms of efficiency.
O(n!) - Factorial
O(2^n) – Exponential
O(n^2) – Polynomial
O(n) – Linear
O(log n ) – Logarithmic
O(1) – Constant
Which Big O Notation has the smallest complexity?
O(1) – Constant
Which Big O Notation has the largest complexity?
O(n!) - Factorial
What is the definition of Dijkstra’s Shortest Path?
An algorithm for finding the shortest path between nodes in a graph.
What are some key facts of Dijkstra’s Shortest Path? ( 3 points)
What are the steps of Dijkstra’s Algorithm? (6 points !)
What is the definition of the A* Algorithm?
A graph traversal algorithm that finds the shortest path between two nodes using heuristics
A* vs Dijkstra’s, Advantages and Disadvantages comparing them:
A*
+ Only finds route to chosen mode.
+ More efficient if good heuristic chosen.
Dijkstra’s
+ Finds distance to all nodes.
+ Guaranteed to find the best solution.
What is a Linear search and what is its complexity?
A searching algorithm that checks all items in order.
Time Complexity: O(n)
Space complexity is constant O(1)
Why should you use Linear search?
List doesn’t need to be sorted.
Can be very quick (if you’re lucky)
Doesn’t require additional memory.
How does a linear search work? ( 3 points)
Iterate through all items.
When sough item found, record index.
Return index.
What is a Binary Search and what is its complexity?
A divide and conquer algorithm that splits data until it finds the sought item.
Complexity: O(log n)
What are some key facts of the Binary Search?
List must be sorted.
Scales very well with large data sets
Doesn’t require extra memory
Runs on a loop ( not recursion)
What is the Quick Sort Algorithm and what is its complexity in both the normal and worst case?
A recursive, divide and conquer algorithm that sorts a list
Time Complexity: O(n log n)
Time Worse Case: O(n^2)
Space is O(log n)
What is a pivot?
A chosen point in a list. We aim to have all larger numbers to the right and all smaller numbers to the left.
What are some key facts of Quick Sort Algorithm? ( 3 points)
What is the Bubble sort and what is it’s time and space complexity?
A sorting algorithm that swaps pairs of data until a list is in order.
Time complexity – polynomial O(n^2)
Space complexity – Constant O(1)
How does the bubble sort work? ( 3 points)
What is an insertion sort and what is it’s time and space complexity?
A sorting algorithm that sorts data by placing items into a new list in the correct order
Time complexity – polynomial O(n^2)
Space complexity – Constant O(1)
What is the Merge Sort what is it’s time and space complexity?
A recursive, divide and conquer algorithm that sorts a list
Time – Logarithmic O(n * log n)
Space – Linear O(n)
How does the Merge Sort work?
Merge sort vs Bubble sort, Advantages and Disadvantages comparing them:
Merge Sort
Bubble Sort
What is a Stack?
A last in first out( LIFO)
A data structure usually used to store instructions
TIP:
[Think of water going through a pipe and coming out the other side]