August 2020
Intermediate to advanced
508 pages
11h 53m
English
The following exercises provide you with the opportunity to practice with algorithms in practical situations. The solutions to these exercises are found in the section, Chapter 7.
Use Big O Notation to describe the time complexity of the following function. The function returns true if the array is a “100-Sum Array,” and false if it is not.
A “100-Sum Array” meets the following criteria:
Here is the function:
| | def one_hundred_sum?(array) |
| | left_index = 0 |
| | right_index = array.length - 1 |
| | |
| | while left_index < array.length / 2 |
| | if array[left_index] + array[right_index] ... |
Read now
Unlock full access