Question: In [9]: # Example 1. As an input, a list of numbers of the length N, sorted # in the ascending order, is given. It

 In [9]: # Example 1. As an input, a list of

In [9]: # Example 1. As an input, a list of numbers of the length N, sorted # in the ascending order, is given. It is known that they # form an arithmetic sequence. write a function to compute # the sum of the numbers in a list. In [5]: def sum(numbers): if numbers == [] or len(numbers) == 0: return 0 else: return (numbers[0] + numbers[-1])*len( numbers)/2 In [7]: # Task la. show that the complexity of the algorithm implemented in Example i # is 0(1). In [8]: # Task 1b. write and test a function to compute a similar sum but for numbers # one knows to form a geometric series. In [ ]: # Task 1c. How the complexity will change if it is necessary to check # whether the numbers in the list reatty form an arithmetic sequence? # (Please write an appropriate code for that check.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!