2.3 Algorithms Flashcards
A* algorithm
Approximately finds shortest path between two nodes
Big O notation
A way or classifying algorithms based on their complexity
Breadth first traversal
A method of traversing a graph by using a queue to visit all the neighbours of the current node before doing the same to each of the neighbours until the entire graph has been explored
Depth first traversal
A method of traversing a graph by using a stack to travel as far along one route as possible and then backtracking and doing the same for the remaining routes until the entire graph has been explored
What does Dijkstra’s algorithm use
A priority queue
Space complexity
A measure of the amount of memory space needed by an algorithms to solve a particular problem of a given input size
Time complexity
A measure of the amount of time needed by an algorithm to solve a particular problem of a given input size
Constant time complexity O(1)
Time taken is independent from number of elements inputted
Exponential O(2^n)
Double with every item added
Polynomial time complexity O(n^n)
Proportional to elements inputted to the power of n
Processing power and memory
More processing power means time complexity is less important whereas lots of memory means space complexity is less important
What do you do to reduce the space complexity
Perform all of the changes on the original pieces of data
What do you do to reduce time complexity
Reduce number of embedded loops
Best case time complexity for linear search
O(1)
Best case time complexity for BINARY search
O(1)
Best case time complexity for BUBBLE sort
O(n)