solution:
using quicksort to solve this first sort the array after that find the median index value from that sorted array, for this solution you have to create and separate quicksort function.
def qsort(arr):
if len(arr)<=1:
return arr
pivot = arr[0]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return qsort(left) + middle + qsort(right)
def findMedian(arr):
# Write your code here
sorted_arr = qsort(arr)
median = sorted_arr[len(sorted_arr)//2]
return median