
1108 CHAPTER 14 An Introduction to Data Structures
EXERCISES,PROBLEMS, AND PROJECTS
35. Suppose we modify the code of the push method in the StackArray
class as follows (that is, without incrementing top). What type of
problem could that method create?
public boolean push( Player p )
{
if ( !isFull())// is there room to insert?
{
stack[top] = p;
return true;
}
else
return false;
}
36. Suppose we modify the code of the pop method in the StackArray
class as follows (that is, without decrementing top). What type of
problem could that method create?
public Player pop()throws DataStructureException
{
if ( !isEmpty())// is there an item to delete?
return ( stack[top