Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
Define what an inversion is.
Think about how two people can rank the same items differently.
Why is the brute force method considered inefficient?
Consider how the number of comparisons grows as items increase.
What is an inversion in ranking?
Think about pairs that don't follow the expected order.
True or False: The brute force method has a time complexity of O(n log n).
Consider the efficiency of different methods.
You have two rankings, R1 = [3, 1, 4, 2] and R2 = [4, 3, 2, 1]. Calculate how many inversions exist and detail the method used.
Count all misordered pairs.
Create an algorithm to efficiently count inversions in an array of size n, and analyze its time complexity.
Think about merging sorted arrays.
5 more questions in this section. Enroll free to practise them all.
Enroll free