Questions tagged [stackunderflow]

A stack underflow occurs when trying to remove an object from the operand stack, but the stack is empty.

A is a last in first out (LIFO) abstract data type. Elements can only be added to and removed from the peak (end) of the stack.

When the pop() method is used on an empty stack, the program will give a stack underflow error as there is no element to be removed.

See also:

17 questions
0
votes
2 answers

Stack by pointers in C working except at stack underflow

I implemented stack by using pointers. It is compiling and working but it doesn't underflow when the stack is empty. It gives me some garbage value. I think the problem is something in the create_stack function. I am not getting segfaults no matter…
Aseem Bansal
  • 6,722
  • 13
  • 46
  • 84
0
votes
1 answer

Trouble implementing a proper (underflow protected) pop/peek method in the stack using liked lists

OK, I'm trying to write the stack pop method using linked lists for my C++ homework. Let me just show you the node and list classes first, then tell you the problem: class Node { public: int data; Node* next; Node(int data, Node* next =…
vexe
  • 5,433
  • 12
  • 52
  • 81
1
2