initially top=0,
if top reaches the size then stack is overflow,
else push the element at top of the stack and
increament the value top by 1
if (top == size)
return false; // ** overflow error **
else
{
data[top] = newNode.deepCopy();
top = top + 1;
return true; // push operation successful
}
Solution
initially top=0,
if top reaches the size then stack is overflow,
else push the element at top of the stack and
increament the value top by 1
if (top == size)
return false; // ** overflow error **
else
{
data[top] = newNode.deepCopy();
top = top + 1;
return true; // push operation successful
}

initially top=0, if top reaches the size then stack is overflow.pdf

  • 1.
    initially top=0, if topreaches the size then stack is overflow, else push the element at top of the stack and increament the value top by 1 if (top == size) return false; // ** overflow error ** else { data[top] = newNode.deepCopy(); top = top + 1; return true; // push operation successful } Solution initially top=0, if top reaches the size then stack is overflow, else push the element at top of the stack and increament the value top by 1 if (top == size) return false; // ** overflow error ** else { data[top] = newNode.deepCopy(); top = top + 1; return true; // push operation successful }