Worked Examples
Worked Examples
Section titled “Worked Examples”Example 1
Section titled “Example 1”for (let i = 0; i < n; i++) { console.log(i);}’ O(n)
Example 2
Section titled “Example 2”for (let i = 0; i < n; i++) { for (let j = 0; j < i; j++) { console.log(i, j); }}O(n²)
Example 3
Section titled “Example 3”while (n > 1) { n = Math.floor(n / 2);}O(log n)
Example 4
Section titled “Example 4”for (let i = 0; i < n; i++) { binarySearch(arr);}O(n log n)