60 556
Assignments Done
97,9%
Successfully Done
In April 2018

Answer to Question #62294 in Java | JSP | JSF for Paul

Question #62294
Give an implementation of the size() method for the singularly linked list class, assuming that we did not maintain size as an instance variable
Expert's answer
public int size() {
Node<AnyType> tmp = head;
int size = 0;
if (head == null) {
return size;
} else {
size++;
while (tmp.next != null) {
tmp = tmp.next;
size++;
}
}
return size;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions