One Pager Cheat Sheet
- With Algorithm Complexity and Big O Notation, developers can measure the performance of a program, in terms oftimeandspacecomplexity, to determine the most effective algorithm to use.
- Using Program 1 as an example, we can see the importance of ensuring that algorithms are designed to be as efficient as possible to maximize performance.
- We can use %timeitin a Jupyter Notebook or language interpreter to measure the performance of an algorithm.
- The program took 600 ns±230 nsper loop,4 millisecondsto call customPower, and337291 nanosecondsin total.
- The built-in powfunction took600nanoseconds to raise3to the power4, which is substantially less compared to program 2.
- The execution time for Python, Javascript, and Java was 308 ns,7 ms, and1555964 ns, respectively.
- The efficient choice of algorithms can greatly improve user experience, and this is shown by Program 2being twice as fast asProgram 1, taking only308nanoseconds.
- Big(O) Notation measures the time complexity of an algorithm based on the relationship between the number of inputs and the steps it takes to process them.
- The best complexity metric given is O(log(n)), as it takes logarithmic time in proportion to the input data.
- The execution of a program with Constant Complexityremains the same, regardless of the input size.
- The display_first_cubefunction has a constant algorithm complexity which does not scale with input.
- Thenum_of_inputs- on the x-axis and thesteps- on the y-axis plot out a straight line when graphed.
- A function or algorithm with linear complexitywill require an equal increase in the number of steps required for execution as the number of units in itsinputincreases.
- The display_all_cubesfunction has linear complexity and its execution time increases proportionally with the number of items in theitemslist.
- The complexity of a function increases quadraticallyas the input size increases.
- The display_all_productsfunction in the code iterates throughnitems in an x nloop and outputs agraphshowing the quadratic equation.
- The space complexity of an algorithm can be determined by calculating the memory needed to store its inputs, expressed in terms of Big(O) Notation.
- The space complexity of the display_first_cubeisO(1)(constant), while that of thedisplay_all_cubesisO(n).
- The complexity of an algorithm can be defined as its worst casescenario, which is optimized for the least ideal situation.
- Sorting an array with consecutive elements is a best case scenario, requiring O(n)operations.
- Measuring algorithm performance in terms of time taken and space consumed can be done through Big(O) notation.
- No, O(n)time complexity does not necessarily mean that the algorithm will usennested loops.


