Back to Browse

Find the k th Smallest/Largest Element | Quick Select Algorithm | Optimizing Quick Sort

20.7K views
Premiered Jul 6, 2021
24:27

Finding Kth largest and smallest element of an array in an Optimized way is common software coding interview question asked in amazon, google, facebook, microsoft coding interview round. Here you are given an array of number and an integer K, you need to find the Kth smallest number in the array. There are multiple ways: 1) Brute Force way: Sort the array and the return the kth element of array, time complexity for this is O(nlogn) 2) use extra space and go for min heap, space complexity for this is o(n) and time is O(nlogk) 3) Optimized solution : Use Quick select, which is an optimization on top of quick sort. This algorithm in it's worst case will give o(n2) time complexity but in average case it will run with time complexity of O(n). In this video I have described how quick select works and implemented it as well. You can get the code from below mentioned github link. subscribe to the channel to get more content on : 1) job interview 2) softwares 3) systems design 4) cracking the coding interview 5) algorithms 6) system design interview questions 7) object oriented programming concepts 8) software design patterns You can buy us a coffee at : https://www.buymeacoffee.com/thetechgranth system design: https://youtu.be/jzPSuBiidF4 DS for beginners: https://youtu.be/cxjWjBPPbzI leetcode solutions: https://youtu.be/jVN6Mq0mXJo github: https://github.com/TheTechGranth/thegranths facebook group : https://www.facebook.com/groups/741317603336313/ twitter: https://twitter.com/GranthTech

Download

1 formats

Video Formats

360pmp429.4 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Find the k th Smallest/Largest Element | Quick Select Algorithm | Optimizing Quick Sort | NatokHD