Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 06 · DSA · Clinic: search, trees, graphs and heaps · about 18 min to read

Play it as a journeyTutor comes with a plan

Clinic #19: Kth Largest Element in an Array

Pattern: Heap (size-k) · LC 215

Kth Largest Element
Kth Largest Element · Open board

Ek chhota sa board, jismein numbers ek arrangement mein pin hote jaate hain, top-5 wale notice-board jaisa, aur upar wali jagah hamesha sabse chhoti value rakhti hai. Yehi ulta trick is lesson ka core hai.

Before you start. Bas itna pata ho ki array numbers ki list hai, har number ki apni jagah (index) hoti hai, aur sort karna matlab chhote se bade order mein lagana. Baaki jo naya lagega: heap, root, Big-O, lesson ke andar hi dikhaya jayega.

Lesson 53 of 96 in DSA

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • School ke notice-board pe sirf top 5: pura result sort karna zaroori hai?
  • 1961: Hoare ne quicksort ke ek panne baad isi sawaal ka jawab diya
  • Notice-board line-wise banta hai: sirf ab tak ke top 5 pin karo
  • Ulta kyun? Sabse BADA doondhne ke liye sabse CHHOTA upar
  • Poora sort vs board: kaam kitna bacha
  • 0 · Problem + Constraints
  • 1 · Kitna kaam bacha, ghadi ke saath
  • 4 · Solution Ladder
  • Sol 1 - sort · O(n log n) · Sol 2 - MIN-heap size k · O(n log k) · BEST-general ✅
  • Sol 3 - quickselect · O(n) avg / O(n²) worst · fastest one-shot
  • Minimal MinHeap (interview mein likhne ke liye)
  • 5 · Trace: MIN-heap size 2, nums=[3,2,1,5,6,4]
  • 6 · Interview mein pehli baar, raasta
  • 7 · The Tell
  • Chala ke dekho: sort, heap, quickselect, aur ek bug jo sample pass karta hai
  • Retrieval

Terms it explains: LC 215, chhoti, Top 5, Tony Hoare, quicksort, quickselect, streaming, kamzor, heap, root, O(n log n), O(n log k), sabse bada, BEST-general, pivot, partition, ek hi side, min-heap size k, Clarify, Naive sort, Sirf top-k matters, INSIGHT, Ulta yaad rakho, JS caveat, Edge, Heap (size-k), frequency, 102, 5605, sorted, sabse bade, minimum (root), ek, nahi, Top K Frequent.

Review DSA