Enrol to start learning
Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.
12.9. Implementation of Merge Procedure with Counting
This section
Practice test
11 questions on this section. Wrong answers show you what to read again.
Sign up to take itWhole chapter
Revision test
Mixed questions from across the chapter. Your answers get marked.
Sign up to take itQuick
Flashcard drill
2 cards from this lesson. Good the night before a test.
Try these first
- 1.
Define an inversion in the context of rankings.
Hint
Think about pairs of items in terms of order.
- 2.
What is the time complexity of counting inversions using the brute-force method?
Hint
Consider the number of comparisons you need for each item.
- 3.
What is the time complexity of counting inversions using merge sort?
- O(n^2)
- O(n log n)
- O(n)
Hint
Think about how merging elements affects overall performance.
- 4.
True or False: Every pair of rankings with no inversions are identical.
- True
- False
Hint
Reflect on the definition of inversion.
- 5.
Design an algorithm that counts inversions in O(n log n) time and identify its key components.
Hint
Focus on how merging sorted lists relates to counting inversions.
- 6.
Given two users' ranking lists, A = [3, 1, 2, 5, 4] and B = [2, 1, 3, 5, 4], find the number of inversions between them.
Hint
Consider how to map one ranking into the order of another.
Exercises
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
4 more questions available
Enrol freeQuiz
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
1 more question available
Enrol freeChallenge Problems
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting