Download presentation
Presentation is loading. Please wait.
Published byBryce Wilkerson 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. smallest i = 6 smallest j = 6 N/2 = 6 auxiliary array current Inversions: Total: 0
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. smallest i = 6 smallest j = 6 N/2 = 6 auxiliary array current Inversions: Total: 0
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. smallest i = 6 smallest j = 5 N/2 = 6 2 auxiliary array current Inversions: 6 Total: 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. smallest i = 6 smallest j = 5 N/2 = 6 2 auxiliary array current Inversions: 6 Total: 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. smallest i = 5 smallest j = 5 N/2 = 6 23 auxiliary array current Inversions: 6 Total: 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. smallest i = 5 smallest j = 5 N/2 = 6 23 auxiliary array Inversions: 6 Total: 6 current
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. smallest i = 4 smallest j = 5 N/2 = 6 723 auxiliary array Inversions: 6 Total: 6 current
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. smallest i = 4 smallest j = 5 N/2 = 6 723 auxiliary array Inversions: 6 Total: 6 current
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. smallest i = 3 smallest j = 5 N/2 = 6 71023 auxiliary array Inversions: 6 Total: 6 current
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. smallest i = 3 smallest j = 5 N/2 = 6 71023 auxiliary array Inversions: 6 Total: 6 current
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. smallest i = 3 smallest j = 4 N/2 = 6 7101123 auxiliary array Inversions: 6 + 3 Total: 9
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. smallest i = 3 smallest j = 4 N/2 = 6 7101123 auxiliary array Inversions: 6 + 3 Total: 9
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. smallest i = 2 smallest j = 4 N/2 = 6 710111423 auxiliary array Inversions: 6 + 3 Total: 9
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. smallest i = 2 smallest j = 4 N/2 = 6 710111423 auxiliary array Inversions: 6 + 3 Total: 9
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. smallest i = 2 smallest j = 3 N/2 = 6 71011142316 auxiliary array Inversions: 6 + 3 + 2 Total: 11
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. smallest i = 2 smallest j = 3 N/2 = 6 71011142316 auxiliary array Inversions: 6 + 3 + 2 Total: 11
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. smallest i = 2 smallest j = 2 N/2 = 6 7101114231617 auxiliary array Inversions: 6 + 3 + 2 + 2 Total: 13
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. smallest i = 2 smallest j = 2 N/2 = 6 7101114231617 auxiliary array Inversions: 6 + 3 + 2 + 2 Total: 13
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. smallest i = 1 smallest j = 2 N/2 = 6 710111423181617 auxiliary array Inversions: 6 + 3 + 2 + 2 Total: 13
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. smallest i = 1 smallest j = 2 N/2 = 6 710111423181617 auxiliary array Inversions: 6 + 3 + 2 + 2 Total: 13
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. smallest i = 0 smallest j = 2 N/2 = 6 71011142318191617 auxiliary array Inversions: 6 + 3 + 2 + 2 Total: 13 first half exhausted
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. smallest i = 0 smallest j = 2 N/2 = 6 71011142318191617 auxiliary array Inversions: 6 + 3 + 2 + 2 Total: 13 first half exhausted
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. smallest i = 0 smallest j = 2 N/2 = 6 7101114231819231617 auxiliary array Inversions: 6 + 3 + 2 + 2 + 0 Total: 13 first half exhausted
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. smallest i = 0 smallest j = 1 N/2 = 6 7101114231819231617 auxiliary array Inversions: 6 + 3 + 2 + 2 + 0 Total: 13 first half exhausted
25
25 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. smallest i = 0 smallest j = 0 N/2 = 6 710111423181923251617 auxiliary array Inversions: 6 + 3 + 2 + 2 + 0 + 0 Total: 13 first half exhausted second half exhausted
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.