Programmer joke: Alice and Bob each wrote an algorithm that can only sort the size of solar system planets. Alice came up with one that takes 0.1*n*log(n) milliseconds and got a job in Silicon Valley. Bob came up with one that take 5*n decades and got a tenure at a university and won a Turing award. #CS #Algorithm #BigO #TimeComplexity
#cs #algorithm #bigo #timecomplexity
Time Complexity (Big O) simplified:
- When your calculation is not dependent on the input size, it is a constant time complexity (O(1)).
- When the input size is reduced by half, maybe when iterating, handling recursion, or whatsoever, it is a logarithmic time complexity (O(log n)).
- When you have a single loop within your algorithm, it is linear time complexity (O(n)).
- When you have nested loops within your algorithm, meaning a loop in a loop, it is quadratic time complexity (O(n^2)).
- When the growth rate doubles with each addition to the input, it is exponential time complexity (O2^n).
#timecomplexity #bigo #programming #code #complexity