+ 2

Can anyone explain about queue management .what to do in that.in c++ queue management part 1

What is the thing we need to do actually in that.please help me .....

16th Dec 2020, 5:38 PM
RAVIKIRAN.D
RAVIKIRAN.D - avatar
6 Respuestas
+ 8
RAVIKIRAN.D Queue is a data structure where insertion take place at the end whereas deletion takes place at the begining. So in short the question is saying that create a function *add()* to add another element at the end of the existing array "queue[]" how to do it is already told by Lam Wei Li
17th Dec 2020, 1:51 AM
Arsenic
Arsenic - avatar
16th Dec 2020, 6:13 PM
Lam Wei Li
Lam Wei Li - avatar
+ 10
It's pretty much self explanatory. 1) You create a function 2) Size is always next index You can do: queue[size] = id; size++; Or: queue[size++] = id; They are the same.
16th Dec 2020, 6:16 PM
Lam Wei Li
Lam Wei Li - avatar
+ 1
I've been trying to do this problem for a while and cant get it. this was my attempt void add(int n){ for(int x = 0; x < size; x++){ if(queue[x] == 0){ queue[x] = n; break; } } } For loop to go through array and an if statement to set the n value to the first open spot. I was getting tripped up about the size of the array and how to add them in the right place. Lam Wei Li gave a much simpler way to do it and after seeing it I felt so silly. Some of these prompts are a bit hard to understand at first.
19th Apr 2022, 6:32 PM
Tyler Briand
Tyler Briand - avatar
0
Arsenic Do you have answer to my question?
16th Dec 2020, 6:11 PM
RAVIKIRAN.D
RAVIKIRAN.D - avatar
0
Lam Wei Li Can you explain this
16th Dec 2020, 6:14 PM
RAVIKIRAN.D
RAVIKIRAN.D - avatar