Deck 5: Linked Lists

Full screen (f)
exit full mode
Question
In the following code segment: final int SIZE = 20;// line 1
Int groupSize;// line 2
GroupSize = SIZE;// line 3
GroupSize = groupSize * 2;// line 4
What is the value of groupSize in line 2?

A)0
B)null
C)20
D)40
Use Space or
up arrow
down arrow
to flip the card.
Question
An array-based implementation of an ADT list ______.

A)requires less memory to store an item than a reference-based implementation
B)is not a good choice for a small list
C)has a variable size
D)has items which explicitly reference the next items
Question
In a linear linked list,______.

A)the next reference of each node has the value null
B)the last node references the first node
C)the precede reference of the dummy head node references the last node
D)the next reference of the last node has the value null
Question
The last node of a linear linked list ______.

A)has the value null
B)has a next reference whose value is null
C)has a next reference which references the first node of the list
D)cannot store any data
Question
A linked list contains components,called ______,which are linked to one another.

A)nodes
B)arrays
C)vectors
D)references
Question
In the following code segment: Integer maxNum;
MaxNum = new Integer (15);
______ is a reference variable.

A)Integer
B)maxNum
C)new
D)15
Question
If you attempt to use a reference variable before it is instantiated,a(n)______ will be thrown.

A)IndexOutOfBoundsException
B)InstantiationException
C)IllegalAccessException
D)NullPointerException
Question
Which of the following statements is used to insert a new node,referenced by newNode,at the end of a linear linked list?

A)newNode.setNext(curr);
Prev.setNext(newNode);
B)newNode.setNext(head);
Head = newNode;
C)prev.setNext(newNode);
D)prev.setNext(curr);
NewNode.setNext(curr);
Question
Which of the following exceptions can be thrown if an object cannot be instantiated?

A)IllegalAccessException
B)ArithmeticException
C)IndexOutOfBoundsException
D)NoSuchMethodException
Question
To delete a node N from a linear linked list,you will need to ______.

A)set the reference next in the node that precedes N to reference the node that follows N
B)set the reference next in the node that precedes N to reference N
C)set the reference next in the node that follows N to reference the node that precedes N
D)set the reference next in N to reference the node that follows N
Question
A reference variable declared as a data field within a class has the default value ______.

A)0
B)-1
C)null
D)empty
Question
If a linked list is empty,the statement head.getNext()will throw a(n)______.

A)IllegalAccessException
B)ArithmeticException
C)IndexOutOfBoundsException
D)NullPointerException
Question
When you declare a variable that refers to an object of a given class,you are creating a(n)______ to the object.

A)interface
B)reference
C)method
D)ADT
Question
Which of the following statements deletes the node that curr references?

A)prev.setNext(curr);
B)curr.setNext(prev);
C)curr.setNext(curr.getNext());
D)prev.setNext(curr.getNext());
Question
In Java,every class is ultimately derived from the class _____ through inheritance.

A)String
B)Object
C)Math
D)Exception
Question
Which of the following will be true when the reference variable curr references the last node in a linear linked list?

A)curr == null
B)head == null
C)curr.getNext()== null
D)head.getNext()== null
Question
According to the principle of information hiding,the data fields of a class must be declared as ______.

A)public
B)protected
C)private
D)abstract
Question
Which of the following statements deletes the first node of a linear linked list that has 10 nodes?

A)head.setNext(curr.getNext());
B)prev.setNext(curr.getNext());
C)head = head.getNext();
D)head = null;
Question
A reference variable whose sole purpose is to locate the first node in a linked list is called ______.

A)top
B)front
C)head
D)first
Question
In a reference-based implementation of an ADT list ______.

A)increasing the size of the list can waste storage and time
B)less memory is required to store an item than in an array-based implementation
C)an item explicitly references the next item
D)the location of the item after a particular item is implied
Question
A local reference variable has a default value of null.
Question
Insertion at the end of a linear linked list is a special case.
Question
Which of the following is NOT true about all circular linked lists?

A)every node references a successor
B)the last node references the first node
C)the precede reference of each node references the node that precedes it
D)no node contains null in its next reference
Question
Which of the following is true about all doubly linked lists?

A)each node references both its predecessor and its successor
B)the precede reference of the last node has the value null
C)the last node references the first node
D)the precede reference of the first node references the last node
Question
A dummy head node ______.

A)facilitates adding nodes at the end the linked list
B)is used to store the first item in the linked list
C)is the second node in the linked list
D)is always present,even when the linked list is empty
Question
When a linked list is empty,the value of the head reference is null.
Question
Which of the following is true about a circular doubly linked list?

A)inserting into the first position of the list is a special case
B)deleting from the last position of the list is not a special case
C)the precede reference of the last node has the value null
D)the next reference of the last node has the value null
Question
In a circular doubly linked list,inserting into the first position of the list is a special case.
Question
No node in a circular linked list contains the value null in its next reference.
Question
Each node in a linear linked list references both its predecessor and its successor.
Question
A ______ can be used to store global information about a linked list.

A)head record
B)tail reference
C)precede reference
D)dummy head node
Question
_______ is a process that transforms an object into a stream of bytes that can be saved to and restored from a file.

A)Information hiding
B)Object serialization
C)Encapsulation
D)Inheritance
Question
Which of the following CANNOT be used in a linear linked list?

A)a head node
B)a dummy head node
C)a precede reference
D)a tail reference
Question
A _______ can be used to facilitate adding nodes to the end of a linear linked list.

A)head record
B)dummy head node
C)tail reference
D)precede reference
Question
The constant null can be used as the value of a reference to any type of object.
Question
In Java,the programmer must explicitly deallocate memory.
Question
Every node in a circular linked list has a successor.
Question
In all circular linked lists,______.

A)every node references a predecessor
B)every node references a successor
C)the next reference of the last node has the value null
D)each node references both its predecessor and its successor
Question
A ______ allows the deletion of a node from a linked list without the need to traverse the list to establish a trailing reference.

A)head record
B)dummy head node
C)tail reference
D)precede reference
Question
The ADT list can have an arbitrary length.
Question
In Java,when is an object marked for garbage collection?
Question
What is a dummy head node?
Question
What is the difference between a linked list and an array in terms of their capacity to store data?
Question
What does a traversal operation do?
Question
What is the difference between a linear linked list and a circular linked list?
Question
Write the code segment that is used to insert a new node,referenced by the reference variable newNode,at the beginning of a linear linked list.
Question
Name two advantages of implementing the ADT list as a linked list (reference based)instead of an array.
Question
Write the code fragment to delete the node that the reference variable curr references in a circular doubly linked list?
Question
Name two advantages of implementing the ADT list as an array instead of using a linked list (reference based).
Question
Why is a loop necessary to find an arbitrary node in a linked list?
Question
Write the code segment which is used to insert a new node,referenced by the reference variable newNode,between the nodes referenced by the reference variables prev and curr in a linear linked list.
Question
If the implementation of a linked list maintains information about only one node,the head of the list,how is it able to be a collection of more than one node? In other words,how can we have a linked list of 20 nodes,if the list implementation only stores information about the head node?
Question
What does a node of a linear linked list contain?
Question
Suppose we want to write a loop that traverses a doubly-linked circular linked list.Assume that each node has a prev and a next reference,and the list itself maintains a reference to a head node.What is wrong with this loop header?
for (Node curr = head;curr != head.prev;curr = curr.next)
Question
Write the code fragment to insert a new node that the reference variable newNode references before the node referenced by the reference variable curr in a doubly linked list.
Question
What are the three high-level steps to delete a node from a linear linked list?
Question
What are two advantages of using a reference-based implementation of the ADT list instead of an array-based implementation?
Question
What is a head record?
Question
What are the three high-level steps to insert a new node into a linear linked list?
Question
What information is stored in a reference to an object?
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/60
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 5: Linked Lists
1
In the following code segment: final int SIZE = 20;// line 1
Int groupSize;// line 2
GroupSize = SIZE;// line 3
GroupSize = groupSize * 2;// line 4
What is the value of groupSize in line 2?

A)0
B)null
C)20
D)40
B
2
An array-based implementation of an ADT list ______.

A)requires less memory to store an item than a reference-based implementation
B)is not a good choice for a small list
C)has a variable size
D)has items which explicitly reference the next items
A
3
In a linear linked list,______.

A)the next reference of each node has the value null
B)the last node references the first node
C)the precede reference of the dummy head node references the last node
D)the next reference of the last node has the value null
D
4
The last node of a linear linked list ______.

A)has the value null
B)has a next reference whose value is null
C)has a next reference which references the first node of the list
D)cannot store any data
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
5
A linked list contains components,called ______,which are linked to one another.

A)nodes
B)arrays
C)vectors
D)references
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
6
In the following code segment: Integer maxNum;
MaxNum = new Integer (15);
______ is a reference variable.

A)Integer
B)maxNum
C)new
D)15
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
7
If you attempt to use a reference variable before it is instantiated,a(n)______ will be thrown.

A)IndexOutOfBoundsException
B)InstantiationException
C)IllegalAccessException
D)NullPointerException
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following statements is used to insert a new node,referenced by newNode,at the end of a linear linked list?

A)newNode.setNext(curr);
Prev.setNext(newNode);
B)newNode.setNext(head);
Head = newNode;
C)prev.setNext(newNode);
D)prev.setNext(curr);
NewNode.setNext(curr);
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following exceptions can be thrown if an object cannot be instantiated?

A)IllegalAccessException
B)ArithmeticException
C)IndexOutOfBoundsException
D)NoSuchMethodException
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
10
To delete a node N from a linear linked list,you will need to ______.

A)set the reference next in the node that precedes N to reference the node that follows N
B)set the reference next in the node that precedes N to reference N
C)set the reference next in the node that follows N to reference the node that precedes N
D)set the reference next in N to reference the node that follows N
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
11
A reference variable declared as a data field within a class has the default value ______.

A)0
B)-1
C)null
D)empty
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
12
If a linked list is empty,the statement head.getNext()will throw a(n)______.

A)IllegalAccessException
B)ArithmeticException
C)IndexOutOfBoundsException
D)NullPointerException
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
13
When you declare a variable that refers to an object of a given class,you are creating a(n)______ to the object.

A)interface
B)reference
C)method
D)ADT
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following statements deletes the node that curr references?

A)prev.setNext(curr);
B)curr.setNext(prev);
C)curr.setNext(curr.getNext());
D)prev.setNext(curr.getNext());
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
15
In Java,every class is ultimately derived from the class _____ through inheritance.

A)String
B)Object
C)Math
D)Exception
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
16
Which of the following will be true when the reference variable curr references the last node in a linear linked list?

A)curr == null
B)head == null
C)curr.getNext()== null
D)head.getNext()== null
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
17
According to the principle of information hiding,the data fields of a class must be declared as ______.

A)public
B)protected
C)private
D)abstract
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following statements deletes the first node of a linear linked list that has 10 nodes?

A)head.setNext(curr.getNext());
B)prev.setNext(curr.getNext());
C)head = head.getNext();
D)head = null;
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
19
A reference variable whose sole purpose is to locate the first node in a linked list is called ______.

A)top
B)front
C)head
D)first
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
20
In a reference-based implementation of an ADT list ______.

A)increasing the size of the list can waste storage and time
B)less memory is required to store an item than in an array-based implementation
C)an item explicitly references the next item
D)the location of the item after a particular item is implied
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
21
A local reference variable has a default value of null.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
22
Insertion at the end of a linear linked list is a special case.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following is NOT true about all circular linked lists?

A)every node references a successor
B)the last node references the first node
C)the precede reference of each node references the node that precedes it
D)no node contains null in its next reference
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
24
Which of the following is true about all doubly linked lists?

A)each node references both its predecessor and its successor
B)the precede reference of the last node has the value null
C)the last node references the first node
D)the precede reference of the first node references the last node
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
25
A dummy head node ______.

A)facilitates adding nodes at the end the linked list
B)is used to store the first item in the linked list
C)is the second node in the linked list
D)is always present,even when the linked list is empty
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
26
When a linked list is empty,the value of the head reference is null.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
27
Which of the following is true about a circular doubly linked list?

A)inserting into the first position of the list is a special case
B)deleting from the last position of the list is not a special case
C)the precede reference of the last node has the value null
D)the next reference of the last node has the value null
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
28
In a circular doubly linked list,inserting into the first position of the list is a special case.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
29
No node in a circular linked list contains the value null in its next reference.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
30
Each node in a linear linked list references both its predecessor and its successor.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
31
A ______ can be used to store global information about a linked list.

A)head record
B)tail reference
C)precede reference
D)dummy head node
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
32
_______ is a process that transforms an object into a stream of bytes that can be saved to and restored from a file.

A)Information hiding
B)Object serialization
C)Encapsulation
D)Inheritance
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
33
Which of the following CANNOT be used in a linear linked list?

A)a head node
B)a dummy head node
C)a precede reference
D)a tail reference
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
34
A _______ can be used to facilitate adding nodes to the end of a linear linked list.

A)head record
B)dummy head node
C)tail reference
D)precede reference
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
35
The constant null can be used as the value of a reference to any type of object.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
36
In Java,the programmer must explicitly deallocate memory.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
37
Every node in a circular linked list has a successor.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
38
In all circular linked lists,______.

A)every node references a predecessor
B)every node references a successor
C)the next reference of the last node has the value null
D)each node references both its predecessor and its successor
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
39
A ______ allows the deletion of a node from a linked list without the need to traverse the list to establish a trailing reference.

A)head record
B)dummy head node
C)tail reference
D)precede reference
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
40
The ADT list can have an arbitrary length.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
41
In Java,when is an object marked for garbage collection?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
42
What is a dummy head node?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
43
What is the difference between a linked list and an array in terms of their capacity to store data?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
44
What does a traversal operation do?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
45
What is the difference between a linear linked list and a circular linked list?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
46
Write the code segment that is used to insert a new node,referenced by the reference variable newNode,at the beginning of a linear linked list.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
47
Name two advantages of implementing the ADT list as a linked list (reference based)instead of an array.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
48
Write the code fragment to delete the node that the reference variable curr references in a circular doubly linked list?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
49
Name two advantages of implementing the ADT list as an array instead of using a linked list (reference based).
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
50
Why is a loop necessary to find an arbitrary node in a linked list?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
51
Write the code segment which is used to insert a new node,referenced by the reference variable newNode,between the nodes referenced by the reference variables prev and curr in a linear linked list.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
52
If the implementation of a linked list maintains information about only one node,the head of the list,how is it able to be a collection of more than one node? In other words,how can we have a linked list of 20 nodes,if the list implementation only stores information about the head node?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
53
What does a node of a linear linked list contain?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
54
Suppose we want to write a loop that traverses a doubly-linked circular linked list.Assume that each node has a prev and a next reference,and the list itself maintains a reference to a head node.What is wrong with this loop header?
for (Node curr = head;curr != head.prev;curr = curr.next)
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
55
Write the code fragment to insert a new node that the reference variable newNode references before the node referenced by the reference variable curr in a doubly linked list.
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
56
What are the three high-level steps to delete a node from a linear linked list?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
57
What are two advantages of using a reference-based implementation of the ADT list instead of an array-based implementation?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
58
What is a head record?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
59
What are the three high-level steps to insert a new node into a linear linked list?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
60
What information is stored in a reference to an object?
Unlock Deck
Unlock for access to all 60 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 60 flashcards in this deck.