Comments on: My Favorite Interview Question /2011/05/30/my-favorite-interview-question/?utm_source=rss&utm_medium=rss&utm_campaign=my-favorite-interview-question Information Retrieval and Machine Learning Fri, 02 Nov 2012 20:40:00 +0000 hourly 1 http://wordpress.org/?v=3.3 By: Sumesh /2011/05/30/my-favorite-interview-question/#comment-7035 Sumesh Fri, 28 Sep 2012 14:38:07 +0000 /?p=157#comment-7035 well said, excellent explanation ...thanks a lot. well said, excellent explanation …thanks a lot.

]]>
By: Arden /2011/05/30/my-favorite-interview-question/#comment-278 Arden Sat, 15 Oct 2011 16:29:38 +0000 /?p=157#comment-278 Ok, now I get it. That's a great idea! Sorry for the confusion. Yes the time complexity would be O(N) and space complexity would be O(logN) which is the stack space of recursion. I'll add this solution to the post by mentioning you. Ok, now I get it. That’s a great idea! Sorry for the confusion. Yes the time complexity would be O(N) and space complexity would be O(logN) which is the stack space of recursion. I’ll add this solution to the post by mentioning you.

]]>
By: Ugur /2011/05/30/my-favorite-interview-question/#comment-276 Ugur Sat, 15 Oct 2011 09:46:50 +0000 /?p=157#comment-276 I mean in the progress of the algorithm it recurse with the left and the right sets which represents the elements that are on the left of the selected and the right of the selected. So we can return the "left set" instead of returning the kth element and that would be O(N) I guess. I mean in the progress of the algorithm it recurse with the left and the right sets which represents the elements that are on the left of the selected and the right of the selected. So we can return the “left set” instead of returning the kth element and that would be O(N) I guess.

]]>
By: Arden /2011/05/30/my-favorite-interview-question/#comment-274 Arden Sat, 15 Oct 2011 05:11:35 +0000 /?p=157#comment-274 Good idea, but we want to return all k minimum elements, instead of just the kth minimum element. So we can perform the selection algorithm k times for i=[1, k]. As a result, the complexity would be O(Nk). Good idea, but we want to return all k minimum elements, instead of just the kth minimum element. So we can perform the selection algorithm k times for i=[1, k]. As a result, the complexity would be O(Nk).

]]>
By: Ugur /2011/05/30/my-favorite-interview-question/#comment-273 Ugur Fri, 14 Oct 2011 23:50:42 +0000 /?p=157#comment-273 Sorry I forgot the link after writing here:) ==> http://en.wikipedia.org/wiki/Selection_algorithm Sorry I forgot the link after writing here:) ==>

]]>
By: Ugur /2011/05/30/my-favorite-interview-question/#comment-272 Ugur Fri, 14 Oct 2011 23:49:05 +0000 /?p=157#comment-272 Nice question, I'm not sure but maybe you can use the worst case N time selection algorithm which is referred as Linear general selection algorithm - Median of Medians algorithm here, you can choose the kth element in linear time and take the elements in the left set of course this will add O(N) space complexity if you don't want to destroy the data but you have it with the heap already :) Nice question,
I’m not sure but maybe you can use the worst case N time selection algorithm which is referred as Linear general selection algorithm – Median of Medians algorithm here, you can choose the kth element in linear time and take the elements in the left set of course this will add O(N) space complexity if you don’t want to destroy the data but you have it with the heap already :)

]]>
By: Li /2011/05/30/my-favorite-interview-question/#comment-194 Li Mon, 26 Sep 2011 02:38:42 +0000 /?p=157#comment-194 nice one. It really demonstrate when to use a heap. nice one. It really demonstrate when to use a heap.

]]>
By: Arden /2011/05/30/my-favorite-interview-question/#comment-67 Arden Sun, 31 Jul 2011 21:37:13 +0000 /?p=157#comment-67 Tesekkurler Ege! :) Tesekkurler Ege! :)

]]>
By: Ege /2011/05/30/my-favorite-interview-question/#comment-66 Ege Sun, 31 Jul 2011 21:13:00 +0000 /?p=157#comment-66 Arden guzel yazi olmus eline saglik :) Arden guzel yazi olmus eline saglik :)

]]>
By: mert /2011/05/30/my-favorite-interview-question/#comment-12 mert Sat, 04 Jun 2011 03:18:47 +0000 /?p=157#comment-12 yorumla geliyorum sana. if n is large compared to k ( k << n), and numbers are uniformly distributed, as long you compare each element with the smallest of the current set of top-k elements (stored as a list/array) the expected complexity will still be linear without using a heap. yorumla geliyorum sana.
if n is large compared to k ( k << n), and numbers are uniformly distributed, as long you compare each element with the smallest of the current set of top-k elements (stored as a list/array) the expected complexity will still be linear without using a heap.

]]>