Random Wits

Life is too short for a diary


$ latest projects
     ├── encrypted-files
├── binary-semaphore
├── AES
└── DES
view all


$ random stuff
├── my bookshelf
    ├── resources
    └── about me
say Hello

Back to Top

Posts Tagged “max-heap”

Sun 20 Mar 2016

Find kth largest element in an array

The other day I stumble upon the question to find the kth largest element in the array. At first glance, I thought the solution was trivial. But later I thought that there are multiple ways to achieve efficient solution

Heap is a useful data structure when root of the tree is important. Extracting an element from the heap is in logarithmic time. This could be used to find kth element from the array since finding maximum or minimum in heap is constant time...

Continue reading → algorithm ruby heap max-heap