#K47157. Median of Two Sorted Arrays
Median of Two Sorted Arrays
Median of Two Sorted Arrays
Given two sorted arrays (which may be empty) provided via standard input, your task is to compute the median of the two sorted arrays combined. The arrays are provided on two separate lines with space‐separated integers. If a line is empty, it represents an empty array.
The median is defined as the middle value of a sorted list if the total number of elements is odd and as the average of the two middle values if the total number of elements is even. The expected algorithm should run in time, where and are the sizes of the arrays.
inputFormat
The input consists of two lines. The first line contains the first sorted array and the second line contains the second sorted array. Numbers on each line are space‐separated. An empty line indicates an empty array.
outputFormat
Output a single floating‐point number representing the median of the merged array. The output should be printed to standard output.## sample
1 3
2
2.0