Question: Question 1 : Consider the following two implementations of a function that if given a list, lst , create and return a new list containing
Question :
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 reverselst: revlst
i
whilei lenlst:
revlstinsert lsti
i return revlst
def reverselst: revlst
i lenlst while i :
revlstappendlsti
i return revlst
If lst is a list of n integers,
WhatistheworstcaserunningtimeofreverselstExplainofyour
answer.
WhatistheworstcaserunningtimeofreverselstExplainofyour
answer.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
