subject

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.
Here is sample code:
def reverse(lyst):
//Write code here
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()

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:00
Write a program that uses a widgetviewer object to do the following: generate two random integers between 1 and 9 (inclusive). name one of them x, the other y. display them to the user using jlabel objects. create a jlabel object displaying the text "enter an operation number." create a jtextfield for the user's input. create a jbutton displaying the text "press here when you've entered your operation." use addandwait to add it to the widgetviewer object. when the user clicks the jbutton, evaluate operation in the following order to determine the one and only mathematical operation to perform on x and y. use a jlabel to display the result. if operation is between 1 and 10 inclusive, add x and y. if operation is evenly divisible by 4, subtract y from x. if operation is evenly divisible by 5, use integer division to divide y into x. if operation is an even number, use floating point division to divide y into x. if none of the other tests on operation apply, multiply x and y. note: operation can be negative or zero.
Answers: 2
question
Computers and Technology, 23.06.2019 00:30
Quick pl which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
question
Computers and Technology, 23.06.2019 02:30
What is the power dissipated by a resistor with a current of 0.02 a and a resistance of 1,000 ? a. 200 w b. 20 w c. 0.4 w d. 4 w
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Anetwork security application that prevents access between a private and trusted network and other untrusted networks
Answers: 1
You know the right answer?
The list method reverse reverses the elements in the list. Define a function named reverse that reve...
Questions
question
Mathematics, 25.08.2021 01:30
question
Engineering, 25.08.2021 01:30
question
Mathematics, 25.08.2021 01:30
question
Mathematics, 25.08.2021 01:30
question
Mathematics, 25.08.2021 01:30
Questions on the website: 13722360