Linked Data Structure Flashcards
The linked list constructor sets the head instance variable to a reference to an empty node.
False - head is set to null.
Erasing a reference to a node always results in it being deleted by the garbage collector.
False - only if there aren’t any other references to it.
The method deleteHeadNode() removes the first node from the list, and head now points to what was the second node in the list.
True.
A node inner class should be defined as private, unless used elsewhere.
True.
How many attributes are there (at minimum) in the node class of a doubly linked list?
3
When can a generic linked list use the clone method to create a deep copy?
If the type parameter is bounded such that the type must implement a custom interface, which itself extends cloneable and makes the clone() method public (instead of protected).
Define the head attribute of a generic linked list.
private Node<T> head;</T>
To define an equals() method for a generic linked list, equals() must be defined for the type parameter T.
True.
If a non-generic class called LinkedList2 has an inner (non-static) iterator class called Iterator2, how would you construct an instance of this iterator in the driver?
LinkedList2 list = new LinkedList2();
LinkedList2.Iterator2 i = list.new Iterator2();
What are the 3 basic methods defined in and used by an Iterator class?
A restart, hasNext and next method.
Java has an Iterator interface that specifies how Java would like an iterator to behave.
True.