Exercises Videos Notes Multiple-choice questions

Related books

Algorithms Algorithm Design Algorithms Suggest a Book
1

Top K elements in a read only array

Level: unknown
 

posted Jul 01 '12

rizwanhudda gravatar image rizwanhudda
21 1 3

updated Jul 11 '12

Given a read only array of $n$ integers, find the $k$ largest numbers in the array in $O(n)$ time possibly using $O(k)$ extra space.

EDIT: Note $k$ is not a constant, so when I say $O(n)$ the constant factor in $O(n)$ shouldn't depend on k.

Source: folklore
Printable version LaTeX source
delete flag offensive retag edit

Comments

@rizwanhudda : k is not a constant... i.e., the constants within O(n) should be independent of k.... right ?

Shiva Kintali (Jul 05 '12)edit

@kintali Yes. k is not constant.

rizwanhudda (Jul 11 '12)edit

Stats

Posted: Jul 01 '12

Seen: 137 times

Last updated: Jul 11 '12