Count Inversions in an array | Set 1 (Using Merge Sort) | GeeksforGeeks

  Рет қаралды 181,408

GeeksforGeeks

GeeksforGeeks

7 жыл бұрын

Explanation for the article: www.geeksforgeeks.org/counting...
This video is contributed by Harshit Jain.

Пікірлер: 47
@AnhTu-en9gk
@AnhTu-en9gk 3 жыл бұрын
This is awesome. I come here from an algorithm course from Stanford. Your explanation is clearer.
@ceciliaw1065
@ceciliaw1065 Жыл бұрын
Amazing amazing explanation with examples, thank you so much
@maximilianoromayfigueroa1815
@maximilianoromayfigueroa1815 4 жыл бұрын
thanks for the awesome video, I learned a lot and in a very short period of time ;)
@GeeksforGeeksVideos
@GeeksforGeeksVideos 7 жыл бұрын
Correction at 05:58 --> "the index of element 3 is smaller than the index of element 2." Correction at 10:53 --> "Time Complexity for Simple Method is O(n^2)." [It can also be written as O(n*n)]
@MrSrikanthpai
@MrSrikanthpai 3 жыл бұрын
Nice explanation. Liked it.
@deniz.7200
@deniz.7200 Жыл бұрын
Thanks for the video, should we also count the inversion happened before merge started??
@goutamkundu6392
@goutamkundu6392 7 жыл бұрын
in the video 08.50 it is "we add the inversion count returned by these two respective calls to inversion count variable". But I am seeing only in the last call inv_count += _mergeSort(arr,temp,mid+1,right) is there
@GeeksforGeeksVideos
@GeeksforGeeksVideos 7 жыл бұрын
Thanks for pointing it out, Goutam. You're right, it's a typo. There should be a plus sign there. The statement should look like this: inv_count += _mergeSort(arr, temp, left, mid);
@alieser7770
@alieser7770 5 жыл бұрын
you are the best!!!
@ariabanazadeh1016
@ariabanazadeh1016 5 жыл бұрын
just amazing
@kautukraj
@kautukraj 4 жыл бұрын
Very helpful!
@MisterAadj
@MisterAadj 4 жыл бұрын
geek4geeks u guys awesome
@lovleshbhatt7797
@lovleshbhatt7797 4 жыл бұрын
Please increase the volume level, its quite less for hearing & understanding
@dsadaddy8403
@dsadaddy8403 2 жыл бұрын
its fine increase yours.
@lalithsamanthapuri932
@lalithsamanthapuri932 7 жыл бұрын
Thanks a Lot Sir..
@GeeksforGeeksVideos
@GeeksforGeeksVideos 7 жыл бұрын
You're welcome!
@subham-raj
@subham-raj 4 жыл бұрын
Why did you take "temp" array?
@pranavsingh9284
@pranavsingh9284 2 жыл бұрын
Merge karenge to extra , to merged to temp le lete apan kyu ki inplace merging nhi kr sakte
@tanishqupadhayay1350
@tanishqupadhayay1350 4 жыл бұрын
why do we add mid-i to inv_count??
@davemustainejigsaw
@davemustainejigsaw 7 жыл бұрын
hi, the method 1 described in the code , shouldn't the condition be if((arr[i] > arr[j])&&(i
@GeeksforGeeksVideos
@GeeksforGeeksVideos 7 жыл бұрын
No, since the inner loop runs from j=i+1 so the (i
@abhishek_sengupta
@abhishek_sengupta 4 жыл бұрын
Thanks a lot!!!
@danielhazel7205
@danielhazel7205 Жыл бұрын
does this work for duplicate numbers in an array?
@adithyabhat4770
@adithyabhat4770 4 жыл бұрын
Thank you so much for the video!
@MadhuKumari-gy7uz
@MadhuKumari-gy7uz 3 жыл бұрын
Cleared my concept, thanks brother
@sanjananl2501
@sanjananl2501 3 жыл бұрын
I am unable to dry run the following two lines of code inv_count += _mergeSort(arr, temp, left, mid); inv_count += _mergeSort(arr, temp, mid + 1, right); in _mergesort. Pls help
@dsadaddy8403
@dsadaddy8403 2 жыл бұрын
share the full code then only we can answer
@kurdi_x5842
@kurdi_x5842 2 жыл бұрын
thamk you helped me alot
@anujg3366
@anujg3366 2 ай бұрын
I came after seeing today gfg potd question :)
@tingzhao3931
@tingzhao3931 Жыл бұрын
nice vid
@_-ghost-_711
@_-ghost-_711 5 жыл бұрын
If I want to print the elements in inversion, then what will be the time complexity.....
@Santosh-om7qk
@Santosh-om7qk 5 жыл бұрын
n^2
@subham-raj
@subham-raj 4 жыл бұрын
It will be nlogn
@subham-raj
@subham-raj 4 жыл бұрын
@@Santosh-om7qk You need to improve your skills
@AdeshPaul
@AdeshPaul 4 жыл бұрын
Samjhane ke liye dhanyavaad. kya aap yeh bta sakte hain ki agar merge sort aur enhanced merge sort ki same time complexities hain to dono me se konsi behtar hai? Agrim Dhanyavaad.
@shubhamlahoti9758
@shubhamlahoti9758 4 жыл бұрын
enhanced one is just for the purpose of counting inversions in array
@vineetkothari2839
@vineetkothari2839 7 жыл бұрын
nice
@soumelee5661
@soumelee5661 Жыл бұрын
4:14 how to get number of inversions ✔✔✅✅ 4:58 examples
@67_ujjwalsolanki78
@67_ujjwalsolanki78 Жыл бұрын
number of likes represent the number of times I fell asleep watching this
@delyartabatabai9636
@delyartabatabai9636 2 жыл бұрын
This is CLRS problem 2-4
@karthikshetty3851
@karthikshetty3851 2 жыл бұрын
It doesnt clear all test Cases
@rupakdas7161
@rupakdas7161 3 ай бұрын
Worst explanation I have ever seen of an algorithm and just reading the lines of code no dry run how can a beginer understand without doing a dry run
@youtube_username_
@youtube_username_ 3 жыл бұрын
It bothers me that he starts talking about mid as if we're supposed to know what mid is.
@FaizaanDatoo
@FaizaanDatoo 3 жыл бұрын
For a more thorough description, I recommend consulting Kleinberg and Tardos: Algorithm Design (the PDF is one of the first results on Google). The relevant text is Chapter 5 - Divide and Conquer, and the section is 5.3 - Counting Inversions. This video helped me understand that section, but I wouldn't have been able to figure it out without both the text and the video.
@DSA_Coding
@DSA_Coding 3 жыл бұрын
boring
@shreyaskulkarni9994
@shreyaskulkarni9994 4 жыл бұрын
Why is he whispering? So annoying
Count Inversions in an Array | Brute and Optimal
24:17
take U forward
Рет қаралды 170 М.
Counting inversions in an array
19:03
Techdose
Рет қаралды 90 М.
你们会选择哪一辆呢#short #angel #clown
00:20
Super Beauty team
Рет қаралды 50 МЛН
3. Divide & Conquer: FFT
1:20:52
MIT OpenCourseWare
Рет қаралды 309 М.
Find the Number Occurring Odd Number of Times | GeeksforGeeks
6:28
GeeksforGeeks
Рет қаралды 46 М.
Counting the Number of Inversions By Divide and Conquer
35:49
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 616 М.
Largest Sum Contiguous Subarray | GeeksforGeeks
14:06
GeeksforGeeks
Рет қаралды 219 М.
Use Arc Instead of Vec
15:21
Logan Smith
Рет қаралды 138 М.
2.6 - Counting Inversions in an Array in O(n log n) time via Divide and Conquer
19:27
Algorithms by Sharma Thankachan
Рет қаралды 10 М.
Count Inversions in Array
11:48
Code with Alisha
Рет қаралды 10 М.
Merge Sort Visualized and Recursion Explained
10:18
Algonatomy
Рет қаралды 8 М.