Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions q3_sol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
def Median(arr):
n = len(arr)
# If length of array is even
if n % 2 == 0:
x = n // 2
y = arr[x]
z = arr[x - 1]
result = (y + z) / 2
return result

# If length of array is odd
else:
x = n // 2
result = arr[x]
return result


if __name__ == "__main__":
arr1 = [ 1,2,3 ]
arr2 = [ 4,5 ]
# Concatenating arrays
arr3 = arr1 + arr2
# Sorting the resultant array
arr3.sort()
print("Median of arrays is = ", Median(arr3))