December 2023
Intermediate to advanced
504 pages
11h 43m
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’s the function:
| | def one_hundred_sum(array): |
| | if (len(array) % 2 != 0) or not array: |
| | return False |
| | |
| | left_index = 0 |
| | right_index = len(array) - 1 |
| | |
| | while left_index < (len(array) ... |
Read now
Unlock full access