Optimize Database Query in Laravel
August 06, 2022
1 min
Big-O notation is the language we use for talking about how long an algorithm takes to run. We can compare two different algorithms or functions using big-O and say which one is better than the other when it comes to scale regardless of our computer differences.
Scaleable there’s actually two things that we want to consider as engineers. One is speed. Other one is memory. Now time complexity is how long it takes the algorithm to run and space complicity is the memory that is required by the algorithm.
function findNemo(array) { for (let i = 0; i < array.length; i++) { if (array[i] === 'nemo) { console.log('Nemo Found!'); } } }
function firstBoxes(array) { console.log(array[0]); }
function pairsOfArray(array) { for (let i = 0; i < array.length; i++) { for (let j = 0; j < array.length; j++) { console.log(i, j); } } }
Source:
https://www.udemy.com/course/master-the-coding-interview-data-structures-algorithms/
Quick Links
Legal Stuff