Question
Let A[1..n] and B[1..n] be two arrays of distinct integers, each sorted in an increasing order. Find the nth smallest of the 2n combined elements.
Let A[1..n] and B[1..n] be two arrays of distinct integers, each sorted in an increasing order. Find the nth smallest of the 2n combined elements.
Your program must run in O(log n) time.
What needs to be turned in:
1. Pseudocode to show the efficiency of your code to be in O(logn) (20%)
2. Demonstrate the correctness of your program in a Meet session (80%)
For example: n = 4
If A[1..n] = {2, 5, 8, 9} and B[1..n] = {1, 4, 6, 7}
The nth (i.e. 4th) smallest integer is 5.
If A[1..n] = {2, 5, 8, 13} and B[1..n] = {1, 9, 10, 15}
Then nth smallest integer is 8.
Your program must be able to read in the two arrays at runtime.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started