Write a peek method for a stack implemented as a linked structure. You may assume that the implementation has the top element of the stack referenced by a LinearNode reference top.

What will be an ideal response?

```
public T peek() throws EmptyCollectionException
{
if (isEmpty() )
throw new EmptyCollectionException("stack");
T result = top.getElement();
return result;
}
```

Computer Science & Information Technology

You might also like to view...

Operators such as greater than and less than that compare two values are ________ operators

A) conditional B) comparison C) contrasting D) provisional

Computer Science & Information Technology

Word uses the ____, also called a namespace, to refer to a schema.

A. URI B. URL C. URx D. URM

Computer Science & Information Technology