• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

CS Question : Is a Queue Better than a Stack?

Kenji4861

Banned
I was asked this today and just got into some deep thinking.

Is a queue better than a stack or a stack better than a queue?

Assuming the queue is not double ended.
 
Originally posted by: Kenji4861
I was asked this today and just got into some deep thinking.

Is a queue better than a stack or a stack better than a queue?

Assuming the queue is not double ended.

what was the deep thinking?
 
Originally posted by: robothouse77
Originally posted by: Kenji4861
I was asked this today and just got into some deep thinking.

Is a queue better than a stack or a stack better than a queue?

Assuming the queue is not double ended.

what was the deep thinking?

must not have been that deep because stack and queue differences are obvious.
 
well this was an interview question and as you all said, I feel that they both have a reason for their existance.

But there must be some kind of answer to this. I just wanted to hear what everyone had in mind.
 
I prefer the queue. I think it is smarter and slightly better looking than the stack. I also think the stack smells worse. So there we have it, go with the queue.
 
Originally posted by: Kenji4861
well this was an interview question and as you all said, I feel that they both have a reason for their existance.

But there must be some kind of answer to this. I just wanted to hear what everyone had in mind.

Shens... to try to make up for frivolous post... but

If this is true, than you explain LIFO and FIFO and that it depends on the use, then say you can use a deque or doubled end queue.

But as for theory Queue is more used in hardware/software OS, I believe, because FIFO is the best suited for most scheduling for threads and processes. Stacks are sometimes used for priority scheduling, but otherwise queues are used for anything that requires real-time processes. For regular calculations, it is about equal.
 
Is a Screw Driver or a Hammer better?

C'mon...what kind of deep thinking did you do on this question? Your questions makes as much sense as the one above.
 
I prefer stacks of pancakes to waiting in a queue for something, therefore, I will have to say stacks are better.
 
Originally posted by: Ipno
I prefer stacks of pancakes to waiting in a queue for something, therefore, I will have to say stacks are better.

What about waiting in queue for that stack of pancakes?
 
Originally posted by: jalaram
That's like asking "Is a string better than an integer?".

In that case I think the integer would be better than a string since a sequence of integers can represent a string.
 
Originally posted by: Kenji4861
Originally posted by: jalaram
That's like asking "Is a string better than an integer?".

In that case I think the integer would be better than a string since a sequence of integers can represent a string.

But string can hold any integer, decimal, float, etc
 
Originally posted by: OulOat
Originally posted by: Kenji4861
Originally posted by: jalaram
That's like asking "Is a string better than an integer?".

In that case I think the integer would be better than a string since a sequence of integers can represent a string.

But string can hold any integer, decimal, float, etc

String is 16-32 bits.
Integer 8 bits. Long 16-32 bits. <dependant on platform>

Type casting takes care of that if you know conversion. 😉
 
Back
Top