paint-brush
Kth Largest Element in an Array - Quickselect Using Lomuto Partitioning Scheme.by@kliukovkin
1,652 reads
1,652 reads

Kth Largest Element in an Array - Quickselect Using Lomuto Partitioning Scheme.

by Georgii Kliukovkin6mNovember 11th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

The algorithm is to use a partitioning algorithm from quickselect. We need to find the N-k smallest element in the array. We use a heap to sort an array and keep the top Kth largest element. The algorithm uses the fact that the work done keeps decreasing on each iteration, gives the O(n) runtime. The toughest thing in the algorithm is understanding how the partitioning works is to imagine an array in a sorted array in linear time using the Lomuto algorithm.

Company Mentioned

Mention Thumbnail
featured image - Kth Largest Element in an Array - Quickselect Using Lomuto Partitioning Scheme.
Georgii Kliukovkin HackerNoon profile picture
Georgii Kliukovkin

Georgii Kliukovkin

@kliukovkin

Software Engineer

About @kliukovkin
LEARN MORE ABOUT @KLIUKOVKIN'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Georgii Kliukovkin HackerNoon profile picture
Georgii Kliukovkin@kliukovkin
Software Engineer

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Newsbreak
Joyk
Coffee-web