+ 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 .....
6 Respostas
+ 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
+ 10
A 3 liner code solution:
https://code.sololearn.com/cZL0r3xLCF5Z/?ref=app
+ 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.
+ 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.
0
Arsenic
Do you have answer to my question?
0
Lam Wei Li
Can you explain this