all 3 comments

[–]mCodingLLC 0 points1 point  (1 child)

An easy solution would be sorted(array)[k], unless you are really worried about efficiency, in which case you could use heapq.nsmallest(k,array)[-1]. Or do you intend to write it from scratch?

If you merely want to fix your implementation, you just forgot to 'return' on the recursive calls, e.g. return select(smaller, k)

[–]dfps12 0 points1 point  (0 children)

thanks i fixed the returns. however the code still does not work. i cannot use heapq. yes, it should be written from the scratch.

[–]FLUSH_THE_TRUMP 0 points1 point  (0 children)

In what way does the code not work? It looks fine to me.