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 LearningFri, 02 Nov 2012 20:40:00 +0000hourly1http://wordpress.org/?v=3.3By: Sumesh
/2011/05/30/my-favorite-interview-question/#comment-7035
SumeshFri, 28 Sep 2012 14:38:07 +0000/?p=157#comment-7035well said, excellent explanation ...thanks a lot.well said, excellent explanation …thanks a lot.
]]>By: Arden
/2011/05/30/my-favorite-interview-question/#comment-278
ArdenSat, 15 Oct 2011 16:29:38 +0000/?p=157#comment-278Ok, 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
UgurSat, 15 Oct 2011 09:46:50 +0000/?p=157#comment-276I 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
ArdenSat, 15 Oct 2011 05:11:35 +0000/?p=157#comment-274Good 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
UgurFri, 14 Oct 2011 23:50:42 +0000/?p=157#comment-273Sorry I forgot the link after writing here:) ==> http://en.wikipedia.org/wiki/Selection_algorithmSorry I forgot the link after writing here:) ==>
]]>By: Ugur
/2011/05/30/my-favorite-interview-question/#comment-272
UgurFri, 14 Oct 2011 23:49:05 +0000/?p=157#comment-272Nice 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
LiMon, 26 Sep 2011 02:38:42 +0000/?p=157#comment-194nice 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
ArdenSun, 31 Jul 2011 21:37:13 +0000/?p=157#comment-67Tesekkurler Ege! :)Tesekkurler Ege! :)
]]>By: Ege
/2011/05/30/my-favorite-interview-question/#comment-66
EgeSun, 31 Jul 2011 21:13:00 +0000/?p=157#comment-66Arden guzel yazi olmus eline saglik :)Arden guzel yazi olmus eline saglik :)
]]>By: mert
/2011/05/30/my-favorite-interview-question/#comment-12
mertSat, 04 Jun 2011 03:18:47 +0000/?p=157#comment-12yorumla 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.
]]>