Time Complexity solution codechef

Time Complexity solution codechef – A sorting algorithm A is said to have more time complexity than a sorting algorithm B if it uses more number of comparisons for sorting the same array than algorithm B.

Time Complexity solution codechef

Given that algorithm A uses X comparisons to sort an array and algorithm B uses Y comparisons to sort the same array, find whether algorithm A has more time complexity.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of two space-separated integers X and Y — the number of comparisons used by algorithms A and B to sort the array respectively.

Output Format

For each test case, output on a new line, YES, if the algorithm A has more time complexity than B and NO otherwise.

You may print each character of the string in uppercase or lowercase (for example, the strings YESyEsyes, and yeS will all be treated as identical).

Time Complexity solution codechef

  • 1 \leq T \leq 100
  • 1 \leq X, Y \leq 100

Sample 1:

Input

Output

4
9 9
15 7
10 19
21 20
NO
YES
NO
YES

Time Complexity solution codechef

Test case 1: The number of comparisons used by algorithm A is 9 and that used by B is also 9. Since the number of comparisons used by A is not more than that of BA does not have more time complexity than B.

Test case 2: The number of comparisons used by algorithm A is 15 and that used by B is 7. Since the number of comparisons used by A is more than that of BA does have more time complexity than B.

Test case 3: The number of comparisons used by algorithm A is 10 and that used by B is 19. Since the number of comparisons used by A is not more than that of BA does not have more time complexity than B.

Test case 4: The number of comparisons used by algorithm A is 21 and that used by B is 20. Since the number of comparisons used by A is more than that of BA does have more time complexity than B.

Post navigation

Leave a Reply

Your email address will not be published.