CSE 143
Miniquiz 13
Name:
12/03/2002
Section:
Time : 6 minutes
Consider the following implementation of a stack using a linked
list.
class MyLink{
public Object obj;
public MyLink next;
public MyLink()
{}
}
class Stack{
//pointer to the top element of the the stack
MyLink top;
//constructor
public Stack(){
top=null;
}
//function for checking if the stack is empty
public boolean isEmpty()
{
//here goes the code...
}
// function for pushing an element onto the stack
public void push(Object o)
{
//here goes the code...
}
}
Write down an implementation for the functions
isEmpty() and push() as defined above.