+1 vote
in Data Structures & Algorithms I by (110k points)
What is the condition for two elements arr[i] and arr[j] to form an inversion?

(a) arr[i]<arr[j]

(b) i < j

(c) arr[i] < arr[j] and i < j

(d) arr[i] > arr[j] and i < j

The question is from Arrays Types topic in section Arrays Types of Data Structures & Algorithms I

The question was asked in an international level competition.

1 Answer

+1 vote
by (408k points)
selected by
 
Best answer
Correct choice is (d) arr[i] > arr[j] and i < j

The explanation is: For two elements to form an inversion the necessary condition is arr[i] > arr[j] and i < j. The number of inversions in an array indicate how close or far the array is from being completely sorted.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...