Linked Data Structure Flashcards

1
Q

The linked list constructor sets the head instance variable to a reference to an empty node.

A

False - head is set to null.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Erasing a reference to a node always results in it being deleted by the garbage collector.

A

False - only if there aren’t any other references to it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The method deleteHeadNode() removes the first node from the list, and head now points to what was the second node in the list.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A node inner class should be defined as private, unless used elsewhere.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How many attributes are there (at minimum) in the node class of a doubly linked list?

A

3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When can a generic linked list use the clone method to create a deep copy?

A

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).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Define the head attribute of a generic linked list.

A

private Node<T> head;</T>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

To define an equals() method for a generic linked list, equals() must be defined for the type parameter T.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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?

A

LinkedList2 list = new LinkedList2();
LinkedList2.Iterator2 i = list.new Iterator2();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the 3 basic methods defined in and used by an Iterator class?

A

A restart, hasNext and next method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Java has an Iterator interface that specifies how Java would like an iterator to behave.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly