Those are the two sample problems. First off, I think that overFlow would be true in both cases because you are adding data points to already full lists (and underflow would be false in both cases). But I dont understand what the final version would look like since you're not using pop or dequeue, how can the letter be placed in already occupied nodes? I would think the final version would therefore look exactly the same as the first in both cases? (Not counting the true and false). Am I understanding that properly or am I totally off? Someone please help!
Well for a stack, the top doesn't change, so its going to remain 2. But that really doesn't pertain to my question, I'm wondering about the .items line, what will be in the nodes (whether they will stay the same "v w x y z") or change. I think it's going to stay the same, but I'm not certain.
I'm sorry, I made a mistake there. IF an item is being added to a stack, the top will increase to the newest item. So if the nodes weren't full it would stack.top would be changed to 3. But does that even take effect if something isn't being added to the list? I would think not, though I am not sure. Which goes back to my previous statement of, the part I am really concerned with is whether the .items line will change.
But does that even take effect if something isn't being added to the list?
Calling push() and "adding something to the list" are one and the same.
I think I see where your confusion is coming from. My advice is that you try to mindlessly run the operation in you head and see what happens.
The computer has no built-in notion of free and occupied space. All it sees is space filled with numbers. It's only the way the program treats its data that makes a given space behave as if was free or occupied. In the case of the stack subprogram, items of index <=stack.top are occupied and the rest are empty, regardless of actual content.
Topic archived. No new replies allowed.
You are using a version without Ads of this website. Please, consider donating: