A quick google tells me “A stack is generally First In, Last Out, and a queue is First In First Out.”
Just to be clear, you mean that you now you will be doing one task then see another needing doing and do it instead. Whereas before you would continue doing the current task, with the intention of doing the other when it was completed?
[Sorry if thats blindingly obvious, my computer science knowledge is fairly sparse.]
Say I needed to vacuum the house and complete an essay. If I stack vacuum on top of essay, I’ll be vacuuming first, and then going to do my essay. But if, while I’m vacuuming, I realise the dishes need cleaning and I need to post a letter, I’ll put those on the stack as well, and they’ll get done before the essay because they’re on top. And as long as I can come up with more tasks, I can stack them on top of the essay, and never get around to it.
But with a queue, I do the vacuuming, realise the dishes need doing, and queue that up behind the essay. The essay gets done before the dishes, removing the temptation to generate mindless busywork for myself.
Ah I see, the task currently being done is not part of the stack.
I can see this working with tasks of similar length and difficulty. But what about when one task is significantly shorter than another and partly time dependent? E.g. in this case, while your essay is more important, it might take several hours to do well, during which the dishes will moulder and annoy your flatmate. Whereas the essay will not e altered during that length of time. I acknowledge that this is a possible way to rationalise procrastination, but there would be cases where it was true.
A quick google tells me “A stack is generally First In, Last Out, and a queue is First In First Out.”
Just to be clear, you mean that you now you will be doing one task then see another needing doing and do it instead. Whereas before you would continue doing the current task, with the intention of doing the other when it was completed?
[Sorry if thats blindingly obvious, my computer science knowledge is fairly sparse.]
Say I needed to vacuum the house and complete an essay. If I stack vacuum on top of essay, I’ll be vacuuming first, and then going to do my essay. But if, while I’m vacuuming, I realise the dishes need cleaning and I need to post a letter, I’ll put those on the stack as well, and they’ll get done before the essay because they’re on top. And as long as I can come up with more tasks, I can stack them on top of the essay, and never get around to it.
But with a queue, I do the vacuuming, realise the dishes need doing, and queue that up behind the essay. The essay gets done before the dishes, removing the temptation to generate mindless busywork for myself.
Ah I see, the task currently being done is not part of the stack.
I can see this working with tasks of similar length and difficulty. But what about when one task is significantly shorter than another and partly time dependent? E.g. in this case, while your essay is more important, it might take several hours to do well, during which the dishes will moulder and annoy your flatmate. Whereas the essay will not e altered during that length of time. I acknowledge that this is a possible way to rationalise procrastination, but there would be cases where it was true.
It’s possible, but I’ve never encountered such a situation.
I have fond memories of implementing Priority Queues, back in the day. The algorithm is rather elegant.