CS Question : Is a Queue Better than a Stack?

Kenji4861

Banned
Jan 28, 2001
2,821
0
0
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.
 

rsd

Platinum Member
Dec 30, 2003
2,293
0
76
depends on what you need, the obvious differences is fifo, lifo
 

MetalMat

Diamond Member
Jun 14, 2004
9,692
36
91
Honestly depends on what you are trying to do. Thats like saying is a car better than boat.
 

robothouse77

Golden Member
Jan 21, 2005
1,170
1
0
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?
 

fs5

Lifer
Jun 10, 2000
11,774
1
0
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.
 

Kenji4861

Banned
Jan 28, 2001
2,821
0
0
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.
 

TheNinja

Lifer
Jan 22, 2003
12,207
1
0
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.
 

DaShen

Lifer
Dec 1, 2000
10,710
1
0
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.
 

PricklyPete

Lifer
Sep 17, 2002
14,714
164
106
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.
 

Ipno

Golden Member
Apr 30, 2001
1,047
0
0
I prefer stacks of pancakes to waiting in a queue for something, therefore, I will have to say stacks are better.
 

Kelemvor

Lifer
May 23, 2002
16,930
7
81
Stacks are far better. Find me a woman with nice Stacks and I'll be the first in the Queue to smoke them.
 

ATLien247

Diamond Member
Feb 1, 2000
4,597
0
0
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?
 

Kenji4861

Banned
Jan 28, 2001
2,821
0
0
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.
 

OulOat

Diamond Member
Aug 8, 2002
5,769
0
0
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
 

DaShen

Lifer
Dec 1, 2000
10,710
1
0
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.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |