2
$\begingroup$

Given that we have a stack with 1.000 items, 2 items are added every second and 5 are removed, how long does it take before the bucket is empty?

In: 2/s

Out: 5/s

Stack size: 1.000


I started out with

1.000 / 5 = 200 

But, during those 200 seconds new items enter the bucket:

200 * 2 / 5 = 80 s

There is some repetition involved.

As time is important factor I thought maybe I should look at the different. So the stack is reduced by 3 every second meaning that eventually the stack will be empty.

I thought that time it takes to empty the stack is:

1.000 / 3 = ~333 seconds

Is that correct?

  • 0
    $\left\lceil\frac{1000}{5-2}\right\rceil=334$ seconds.2017-01-24
  • 1
    Are items taken continuously (one every 0.2 seconds) or in a big chunk of five every second? Same question goes for adding. Next thing: If you have 5 left and take them away. Are you done or do you have o look at the next 2 incoming?2017-01-24
  • 0
    Items are discrete. You need to know the order in which order items are added and removed and when to answer this question with subsecond accuracy.2017-01-24
  • 0
    Yes, items are take at an exact interval of 0.2s and added every 0.5s.2017-01-24

3 Answers 3

1

We can consider the sequence $$1000,997,994,\cdots $$ where the $n$th term of the sequence denotes the number of plates remaining in the $n$th second. We can easily see that the general term of the sequence is $1000-3n $. We need to find that value for which this becomes zero, so your value is fine.

However note that after $333$ seconds, there is still one item remaining and there cannot be any fractional time. Hope it helps.

  • 0
    Thanks for mentioning about the fractionals. That makes sense to round it up.2017-01-24
0

Well... The easiest way is to see that you are losing 3 second. So after 333s, you are back to 1. You need an additional second to get down to 0.

0

2 items are added and 5 are removed in 1 second. So overall 3 items are removed in 1 second.

So we have,

$\frac{1000}{3} = 333$ seconds to remove 999 items. And we left with 1.