
X = 4, Y = 6, Z = 2
Here the element with value in the middle is 4, because 2 < 4 < 6.
You need to try doing it using minimum comparisons.
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain three space-separated distinct integers ‘X’, ‘Y’, and ‘Z’.
For each test case, print the number with a value in the middle.
Output for every test case will be printed in a separate line.
You don’t need to print anything, It has already been taken care of. Just implement the given function.
1 <= T <= 50
1 <= X, Y, Z <= 10^9
Where ‘T’ is the number of test cases.
Where ‘X’, ‘Y’, and ‘Z’ denote the distinct numbers.
Time limit: 1 sec
The basic idea is to check for each element to be the middle element. Steps are as follows:
The number of comparisons: 8, in the worst case.
This time, the basic idea is to divide the problem into two parts and then compare the values.
This approach is efficient and uses fewer comparisons than the last one because only one of the outer If-else statements will be executed.
The number of comparisons: 3, in the worst case
In this approach, the basic idea is to use the basic properties of multiplication, that multiplication of two negative numbers is positive, multiplication of two positive numbers is positive and multiplication of one positive number and one negative number is negative.
The number of comparisons: 2, in the worst case.
Pair Product Div by K
Pair Product Div by K
Merge Two Sorted Arrays Without Extra Space
Merge Two Sorted Arrays Without Extra Space
Co-Prime
First Digit One
Special Digit Numbers