2.6 - Counting Inversions in an Array in O(n log n) time via Divide and Conquer

  Рет қаралды 9,954

Algorithms by Sharma Thankachan

Algorithms by Sharma Thankachan

3 жыл бұрын

Given an array A[1,n] of numbers, we need to count the number of inversions.
As inversion is a pair of positions (i, j), such that i is smaller than j, but i-th element is larger than j-th element (i.e, the elements are out of order with respect to sorted order). This can be solved in O(n log n) time via a Divide and Conquer algorithm.

Пікірлер: 10
@javeriyanadaf9314
@javeriyanadaf9314 2 жыл бұрын
Beautifully put together
@elirhm5926
@elirhm5926 Жыл бұрын
the best explaination ever! thank you so much!
@user-gu5bk1og7c
@user-gu5bk1og7c 2 жыл бұрын
some solid work out there
@carlavn2470
@carlavn2470 Жыл бұрын
Shouldn't the counter at 8 be 4?
@algorithmsbysharmathankach7521
@algorithmsbysharmathankach7521 Жыл бұрын
I was counting in the other direction --- i.e.,for each number, how many are on its RIGHT side that are smaller.
@carlavn2470
@carlavn2470 Жыл бұрын
@@algorithmsbysharmathankach7521 right, I get that. But if we are using the R side as a counter, shouldn't the count change to 4 instead of staying as 3 at digit 8?
@algorithmsbysharmathankach7521
@algorithmsbysharmathankach7521 Жыл бұрын
@@carlavn2470 didn't get it, can you tell me where exactly (time in the video) is the mistake?
@carlavn2470
@carlavn2470 Жыл бұрын
@@algorithmsbysharmathankach7521 at min 17:48
@algorithmsbysharmathankach7521
@algorithmsbysharmathankach7521 Жыл бұрын
@@carlavn2470 yes, it is 4 (my bad) -- thankyou!
2.7 - Finding the MIN/MAX slope (of lines connecting points in 2D) and its Counting Version
25:10
2.5 - Closest Pair of Points using Divide and Conquer algorithm in O(n log n) time.
25:05
Algorithms by Sharma Thankachan
Рет қаралды 39 М.
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 7 МЛН
ВОДА В СОЛО
00:20
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 35 МЛН
Best Toilet Gadgets and #Hacks you must try!!💩💩
00:49
Poly Holy Yow
Рет қаралды 22 МЛН
UNO!
00:18
БРУНО
Рет қаралды 2,7 МЛН
Counting inversions in an array
19:03
Techdose
Рет қаралды 91 М.
Count Inversions in an Array | Brute and Optimal
24:17
take U forward
Рет қаралды 187 М.
2.2 - Linear Time Selection (Median of Medians Algorithm)
32:07
Algorithms by Sharma Thankachan
Рет қаралды 20 М.
Counting the Number of Inversions By Divide and Conquer
35:49
SHA: Secure Hashing Algorithm - Computerphile
10:21
Computerphile
Рет қаралды 1,2 МЛН
2.3 - Binary search (in 1D and 2D arrays - upper and lower bounds) and Bitonic search
43:22
Algorithms by Sharma Thankachan
Рет қаралды 1,4 М.
Why Do Bubbles Form In Glasses Of Water?
12:33
Joe Scott
Рет қаралды 78 М.
3   1   On log n Algorithm for Counting Inversions I 13 min
12:36
Stanford Algorithms
Рет қаралды 53 М.
Count Inversions in Array
11:48
Code with Alisha
Рет қаралды 10 М.
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 7 МЛН