diff options
Diffstat (limited to 'progs/a21.py')
-rw-r--r-- | progs/a21.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/progs/a21.py b/progs/a21.py new file mode 100644 index 0000000..b9019f5 --- /dev/null +++ b/progs/a21.py @@ -0,0 +1,25 @@ +def get_median(arr1, arr2, n):
+ i = 0
+ j = 0
+ m1 = -1
+ m2 = -1
+ count = 0
+ while count < n + 1:
+ count += 1
+ if i == n:
+ m1 = m2
+ m2 = arr2[0]
+ break
+ elif j == n:
+ m1 = m2
+ m2 = arr1[0]
+ break
+ if arr1[i] <= arr2[j]:
+ m1 = m2
+ m2 = arr1[i]
+ i += 1
+ else:
+ m1 = m2
+ m2 = arr2[j]
+ j += 1
+ return (m1 + m2)/2
\ No newline at end of file |