August 2020
Intermediate to advanced
508 pages
11h 53m
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 | ? | ? |
2000 | ? | ? | ? |
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:
| | def greatestProduct(array): |
| | greatestProductSoFar = array[0] * array[1] |
| | |
| | for i, iVal in enumerate(array): ... |
Read now
Unlock full access