Learning about Big O

Learning about Big O

What the heck is Big O!?

I'm starting my Data Structure and Algorithm course on Udemy. It's a pretty beginner course which would, hopefully, set me up for understanding the Leetcode problems. Learning about the concept of Big O

1. O(n) - O of n. Iteration

  • Drop the constant(when you have two single for loops)
function logItems(n){
for (let i = 0; i< n; i ++){
console.log(i)
for (let j = 0; j< n; j ++){
console.log(j)

2. O(n^2) - O of n squared. aka loop within a loop

  • Drop Non-Dominants = when you have O(n) and O(n^2) together, you drop O(n).

3. O(1) - O of 1 aka constant time.

  • The most efficient Big O.

4. `O(log n) - O of log n. aka Divide and Conquer

BigO.PNG

#conclusion

Big O is one of the fundamental tools for software engineers to analyze the cost of an algorithm. You can find more info on Big O by following this Link(bigocheatsheet.com)