The list method reverse reverses the elements in the list. Define a function named reverse that reverses the elements in its list argument (without using the inbuilt reverse() list method). Try to...


The list method reverse reverses the elements in the list. Define a function named reverse that reverses the elements in its list argument (without using the inbuilt reverse() list method).


Try to make this function as efficient as possible, and state its computational complexity using big-O notation.



-----------------------------------------------------------------------------------




"""

File: reverse.py

Project 11.2



Defines a function to reverse the elements in a list.

"""



def reverse(lyst):

    # Define your reverse function here without using the inbuilt reverse() method.



def main():

    """Tests with two lists."""

    lyst = list(range(4))

    reverse(lyst)

    print(lyst)

    lyst = list(range(3))

    reverse(lyst)

    print(lyst)



if __name__ == "__main__":

    main()



Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here