You have a list of n integers and you want the x smallest. For example,
x_smallest([1, 2, 5, 4, 3], 3) should return [1, 2, 3].
x_smallest([1, 2, 5, 4, 3], 3)
[1, 2, 3]
I\'ll v
In pseudo code:
y = length of list / 2 if (x > y) iterate and pop off the (length - x) largest else iterate and pop off the x smallest
O(n/2 * x) ?