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
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
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
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
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
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
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 = auxiliary array Inversions: 6 Total: 6 current
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 = auxiliary array Inversions: 6 Total: 6 current
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 = auxiliary array Inversions: 6 Total: 6 current
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 = auxiliary array Inversions: 6 Total: 6 current
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 = auxiliary array Inversions: Total: 9
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 = auxiliary array Inversions: Total: 9
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 = auxiliary array Inversions: Total: 9
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 = auxiliary array Inversions: Total: 9
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 = auxiliary array Inversions: Total: 11
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 = auxiliary array Inversions: Total: 11
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 = auxiliary array Inversions: Total: 13
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 = auxiliary array Inversions: Total: 13
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 = auxiliary array Inversions: Total: 13
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 = auxiliary array Inversions: Total: 13
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 = auxiliary array Inversions: Total: 13 first half exhausted
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 = auxiliary array Inversions: Total: 13 first half exhausted
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 = auxiliary array Inversions: Total: 13 first half exhausted
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 = auxiliary array Inversions: Total: 13 first half exhausted
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 = auxiliary array Inversions: Total: 13 first half exhausted second half exhausted