Computers and Technology

Question 1: Consider the following two implementations of a function that if given a list, lst, create and return a new list containing the elements of lst in reverse order. def reverse1(lst): rev_lst = [] i = 0 while(i < len(lst)): rev_lst. insert(0, lst[i]) i += 1 return rev_lst def reverse2(lst): rev_lst = [] i = len(lst) - 1 while (i >= 0): rev_lst. append(lst[i]) i -= 1 return rev_lst If lst is a list of n integers, 1. What is the worst case running time of reverse1(lst)? Explain of your answer. 2. What is the worst case running time of reverse2(lst)? Explain of your answer.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:00, joshualoz5414
Acase study allows a more detailed look at the life of a single subject than any other study.
Answers: 3
image
Computers and Technology, 22.06.2019 23:30, Molly666
What does 21 pilots middle aged name as a band 15 years prior to them naming their band 21 pilots?
Answers: 1
image
Computers and Technology, 23.06.2019 11:00, danielcano12281621
Sports and entertainment class, your goal is to increase attendance and make a profit for a game by getting your team on a winning track with total salaries less than $3,000,000
Answers: 3
image
Computers and Technology, 23.06.2019 11:00, swelch2010
Describe three characteristics of at-risk drivers. a. b. c. describe three characteristics of safe drivers. a. b. c. describe three driver errors that could cause a collision. a. b. c. how will this information affect you as a driver now and in the future? (2-3 sentences)
Answers: 2
Do you know the correct answer?
Question 1: Consider the following two implementations of a function that if given a list, lst, crea...

Questions in other subjects:

Konu
French, 03.12.2020 14:00
Konu
World Languages, 03.12.2020 14:00