This is the output of my program : Initial Queue 40 30
40 was popped from back 30
New Queue 12 10 8 30
i am having problem with the function push_back, i am try push 12 10 8 after 30. in other words the output should be 30 8 10 12
any suggestions
Printable View
This is the output of my program : Initial Queue 40 30
40 was popped from back 30
New Queue 12 10 8 30
i am having problem with the function push_back, i am try push 12 10 8 after 30. in other words the output should be 30 8 10 12
any suggestions
You listed 40 before 30 above, so does that mean you are listing the numbers back-to-front?
Wait, now it seems like you're saying the opposite. Which is it?Quote:
New Queue 12 10 8 30
i am having problem with the function push_back, i am try push 12 10 8 after 30. in other words the output should be 30 8 10 12
1) Find the last node in the list.
2) Set its next pointer to your new node.
Remember to check the special case of an empty list.
i am not sure if this is right but i dont know have to set the pointer, any hint?
void DeQueue:: push_back(int data)
{
if(front==-1){
storage[0]=data;
front = back = 0;
return;
}
back = (back+1);
storage[back] = data;
}
Okay....the earlier posts made it look like you were using a linked list, but that one looks more like an array. Which is it?