Download presentation
Presentation is loading. Please wait.
Published byDaisy Reed Modified over 9 years ago
1
1 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves auxiliary array Total: i = 6
2
2 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. i = 6 two sorted halves 2 auxiliary array Total: 6 6
3
3 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 2 auxiliary array i = 6 Total: 6 6
4
4 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 23 auxiliary array i = 6 Total: 6 6
5
5 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 23 auxiliary array i = 5 Total: 6 6
6
6 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 723 auxiliary array i = 5 Total: 6 6
7
7 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 723 auxiliary array i = 4 Total: 6 6
8
8 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 71023 auxiliary array i = 4 Total: 6 6
9
9 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 71023 auxiliary array i = 3 Total: 6 6
10
10 1418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 7101123 auxiliary array i = 3 Total: 6 + 3 63
11
11 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 7101123 auxiliary array i = 3 Total: 6 + 3 63
12
12 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 710111423 auxiliary array i = 3 Total: 6 + 3 63
13
13 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 710111423 auxiliary array i = 2 Total: 6 + 3 63
14
14 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 71011142316 auxiliary array i = 2 Total: 6 + 3 + 2 632
15
15 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 71011142316 auxiliary array i = 2 Total: 6 + 3 + 2 632
16
16 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 7101114231617 auxiliary array i = 2 Total: 6 + 3 + 2 + 2 6322
17
17 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 7101114231617 auxiliary array i = 2 Total: 6 + 3 + 2 + 2 6322
18
18 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 710111423181617 auxiliary array i = 2 Total: 6 + 3 + 2 + 2 6322
19
19 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 710111423181617 auxiliary array i = 1 Total: 6 + 3 + 2 + 2 6322
20
20 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 71011142318191617 auxiliary array i = 1 Total: 6 + 3 + 2 + 2 6322
21
21 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 71011142318191617 auxiliary array i = 0 Total: 6 + 3 + 2 + 2 first half exhausted 6322
22
22 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 7101114231819231617 auxiliary array i = 0 Total: 6 + 3 + 2 + 2 + 0 6322 0
23
23 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 710111423181923251617 auxiliary array i = 0 Total: 6 + 3 + 2 + 2 + 0 + 0 6322 0 0
24
24 101418193716172325211 Merge and Count Merge and count step. n Given two sorted halves, count number of inversions where a i and a j are in different halves. n Combine two sorted halves into sorted whole. two sorted halves 710111423181923251617 auxiliary array i = 0 Total: 6 + 3 + 2 + 2 + 0 + 0 = 13 6322 0 0
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.