Part 1 Flashcards
What is a recursive data structure?
A data structure that contains a reference or pointer to another object of the same type
A linked list is a _______ data structure
Recursive
What does the cons operation do with a linked list?
Take a list and a data item and construct a new list by adding the specified data item to the front of the list
What does the head operation do with a linked list?
Returns the first item (the front item) of the list
What does the tail operation do to a linked list?
Return the whole list, except the head
How is an empty reference represented in java?
null
What is the difference between a doubly linked list and a linked list?
Doubly linked list cells have a reference to the previous cell as well as the next one
for a generic class, do you need <t> in the constructor method name?</t>
No
What are the advantages of using doubly linked lists over singly linked lists?
More efficient traversal in both directions, can add and remove at both ends
What is the disadvantage of using doubly linked lists over singly linked lists?
Why is this often not a concern?
More memory space
Not usually a concern because it will only use an extra int (4 bytes) per item which is usually insignificant next to the data structures the list is referencing.
What is the disadvantage of using Object to allow generic classes, rather than <t>?</t>
Using object you have to downcast whenever you want to use the object, also allows objects to be mixed types which is probably not good
When writing generic static methods, it is necessary to
include < T > in the signature after the word static
e.g. public static < T > void addCopies(T s, LList< T > ll, int numcopies)