December 2023
Intermediate to advanced
504 pages
11h 43m
English
The following exercises provide you with the opportunity to practice analyzing algorithms. The solutions to these exercises are found in the section Chapter 5.
Use Big O notation to describe the time complexity of an algorithm that takes 4N + 16 steps.
Use Big O notation to describe the time complexity of an algorithm that takes 2N2.
Use Big O notation to describe the time complexity of the following function, which returns the sum of all numbers of an array after the numbers have been doubled:
| | def double_then_sum(array): |
| | doubled_array = [] |
| | |
| | for number in array: |
| | doubled_array.append(number * 2) |
| | |
| | sum = 0 |
| | |
| | for number in doubled_array: |
| | sum += number |
| | |
| | return sum |
Use Big O notation to describe the time ...
Read now
Unlock full access