Question: Instructions In the reverse.py file, complete the following: 1. Define a function named reverse() that reverses the elements in its list argument. Do not use

 Instructions In the reverse.py file, complete the following: 1. Define a
function named reverse() that reverses the elements in its list argument. Do

Instructions In the reverse.py file, complete the following: 1. Define a function named reverse() that reverses the elements in its list argument. Do not use the List method .reverse(). 2. Try to make the function as efficient as possible. 3. State its computational complexity using big-o notation in the docString/headerDoc. To test your program run the main() method in the reverse.py file. Your program's output should look like the following: [3, 2, 1, 0] [2, 1, 0] 11 1 2 File: reverse.py 3 Project 3.2 4 Defines a function to reverse the elements in a list. 5 Computational complexity: 6 1 1 1 1 7 8 def reverse(lyst): 9 "Reverses the elements in a list in linear time." 10 # Use indexes to the first and last element 11 # and move them toward each other. 12 13 def swap(lyst, x, y): 14 "Exchanges the elements at positions x and y. 15 16 def main(): 17 Tests with two lists." 18 lyst = list (range (4)) 19 reverse(lyst) 28 print(lyst) lyst = list(range (3)) 22 reverse(lyst) 23 print(lyst) 24 25 if __main__": 26 main() 27 28 21 -name__

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!