Question: Task 1 . Implement your function to perform a one - time reversal on the input sequence perform _ reversal ( data , a ,

Task 1. Implement your function to perform a one-time reversal on the input sequence
perform_reversal(data, a, b) function implementation
Give a list of values data, and two indices a and b (a < b), you must produce and return a new list that reflects a reversal of all the values from index a to b inclusive. For example, a call to
perform_reversal([0,5,4,1,3,2,6],2,5)
should return the list [0,5,2,3,1,4,6]
Note: Make sure to keep the first value and last value in the input list always be same as the first value is always to be 0, and the last value is always to be the maximum. Just need to move the order of the intermediate values.
def perform_reversal(data, a, b): """Return a new sequence that reflects inverting the portion of data from indices a to b, inclusive. """

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 Programming Questions!