Question:

Consider the following Python function :
def fun (D, s1, s2) :
if s1 s2:
D[s1], D[s2] = D[s2], D[sl]
fun (D, s1+1, s2-1)
What does this Python function fun () do? Select the ONE appropriate option below.

Updated On: Jul 9, 2024
  • It finds the smallest element in D from index s1 to s2, both inclusive.
  • It performs a merge sort in-place on this list D between indices s1 and s2, both inclusive.
  • It reverses the list D between indices s1 and s2, both inclusive.
  • It swaps the elements in D at indices s1 and s2, and leaves the remaining elements unchanged.
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

The correct option is (C) : It reverses the list D between indices s1 and s2, both inclusive..
Was this answer helpful?
0
0

Questions Asked in GATE AR exam

View More Questions