test for Big O, sorting and searching Flashcards
complexity is
the amount of time and space that an algorithm requires to be executed
what is an example of a logarithmic complexity
binary search
what is an exmaple of an algorithm with pylonomial complexity O (n^2)
bubble sort, insertion sort
what is the time complexity of a recursive algorithm
Exponential O(2^n)
what is the best time complexity for all the search algorithms
O(1)
what is the worst time complexity for a quick sort
O(n^2)
what is the worst time complexity for hashing
O(n)
what is the best and the average / worst time complexity for insertion and bubble sort
best : O(n)
worst/average: O(n^2)
what is heuristics
it estimates the shortest path from the start node.
it is used to improve efficiency as it prioritises nodes that are likely to lead to the shortest path
what is the difference between A* and dijkstras
D explores all the nodes in a graph, finding the shortest path without considering heuristics
A* uses heuristics to prioritize nodes with the lowest estimated cost, improving efficiency