• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE | DA 2024 | Question 18

Consider the following Python function:

def fun(D, s1, s2):
 if s1 < s2:
 D[s1], D[s2] = D[s2], D[s1]
 fun(D, s1+1, s2-1)

What does this Python function fun() do? Select the ONE appropriate option below.
 

(A)

It finds the smallest element in D from index s1 to s2, both inclusive. 

(B)

It performs a merge sort in-place on this list D between indices s1 and s2, both inclusive.
 

(C)

It reverses the list D between indices s1 and s2, both inclusive

(D)

It swaps the elements in D at indices s1 and s2, and leaves the remaining elements unchanged.
 

Answer

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments