Write the header and body for isEmpty. The method returns true if the list is empty and false otherwise. Does the method need to know if the underlying implementation uses an array or a list structure?
What will be an ideal response?
isEmpty can be determined from a call to size, and does not need to know how the list is implemented. Here are two
possible solutions:
```
public boolean isEmpty()
{
if (size() == 0)
return true;
else
return false;
}
```
```
public boolean isEmpty()
{
return (size() == 0);
}
```
You might also like to view...
Which of the following traversals never visits the root?
a) Preorder b) Inorder c) Postorder d) Level-order e) none of the above
The comment and ________ will show when you point to a worksheet cell containing a comment
A) the name of the comment creator B) the priority rating of the comment C) the date the comment was created D) related comments
Choose the sentence that demonstrates correct punctuation of words to which the writer wishes to draw attention.?
A. ?Playhardball and throw in the towel are examples of sports jargon that have become part of everyday speech. B. ?"Play hardball" and "throw in the towel" are examples of sports jargon that have become part of everyday speech. C. ?Play hardballand throw in the towel are examples of sports jargon that have become part of everyday speech.
In a peer-to-peer network, any system acts as a server or client, but no one system can be both.
Answer the following statement true (T) or false (F)