August 2024
Intermediate to advanced
516 pages
11h 47m
English
The following exercises provide you with the opportunity to practice with speeding up your code. The solutions to these exercises are found in the section Chapter 4.
Replace the question marks in the following table to describe how many steps occur for a given number of data elements across various types of Big O:
N Elements | O(N) | O(log N) | O(N2) |
|---|---|---|---|
100 | 100 | ? | ? |
2,000 | ? | ? | ? |
If we have an O(N2) algorithm that processes an array and find that it takes 256 steps, what is the size of the array?
Use Big O notation to describe the time complexity of the following function. It finds the greatest product of any pair of two numbers within a given array:
| | function greatestProduct(array) { |
| | if (array.length < 2) { return null; } |
| | |
| | let greatestProductSoFar ... |
Read now
Unlock full access