Deck 17: Linked Lists

Full screen (f)
exit full mode
Question
A doubly linked list can be traversed in either direction.
Use Space or
up arrow
down arrow
to flip the card.
Question
Data can be organized and processed sequentially using an array, called a(n) ____ list.

A) linked
B) ordered
C) sequential
D) ascending
Question
It is not possible to create an ordered linked list.
Question
In a linked list, the order of the nodes is determined by the address, called the ____, stored in each node.

A) head
B) tail
C) link
D) first
Question
When you build a linked list in the backward manner, a new node is always inserted at the end of the linked list.
Question
A linked list is a collection of components, called ____.

A) elements
B) nodes
C) members
D) pointers
Question
Suppose that the pointer head points to the first node in the list, and the link of the last node is NULL. The first node of the linked list contains the address of the ____ node.

A) head
B) first
C) second
D) tail
Question
You can use the pointer head of a linked list to traverse the list.
Question
A linked list is a random access data structure.
Question
Memory for the components of an array does not need to be contiguous.
Question
What is the purpose of the following code? current = head;
While (current != NULL)
{
//Process current
Current = current->link;
}

A) Insertion of a node
B) Selection of a node
C) Traversal of a linked list
D) Creation of a new list
Question
Linked lists allow you to overcome the size limitations of an array data type.
Question
In a linked list, if a new item is always inserted at the beginning or at the end of the list and the data we read is unsorted, the linked list will be unsorted.
Question
We deallocate the memory for a linked list by calling the operator clear.
Question
The link field of the last node of a linked list is ____.

A) NULL
B) 1
C) n-1
D) n
Question
Each node of a singly linked list has two components: ____ and ____.

A) info, head
B) link, back
C) back, head
D) info, link
Question
Because each node of a linked list has two components, we need to declare each node as a(n) ____.

A) reference and string
B) int and object
C) index and element
D) class or struct
Question
In a linked list, the address of the first node in the list is stored in a separate location, called the ____ or first.

A) head
B) pointer
C) front
D) top
Question
The length of a linked list is the number of nodes in the list.
Question
Every node (except of the last node) in a singly linked list contains ____.

A) the next node
B) no address information
C) the address of the next node
D) the address of the previous node
Question
Which of the following statements appears in the insert function of a doubly linked list?

A) current++;
B) trailCurrent++;
C) newNode++;
D) count++;
Question
Consider the following code which deletes all the nodes in a linked list. void doublyLinkedList::destroy()
{
NodeType *temp; //pointer to delete the node
While (first != NULL)
{
Temp = first;
First = first->next;
____
}
Last = NULL;
Count = 0;
}
Which of the following is the missing statement?

A) delete first;
B) delete temp;
C) destroy temp;
D) clear temp;
Question
Each node of a linked list must store the data as well as the ____________________ for the next node in the list
Question
A(n) ____________________ is an object that produces each element of a container, such as a linked list, one element at a time.
Question
template
____ doublyLinkedList::isEmptyList() const
{
return (first == NULL);
}
Consider the statements above. The operation returns true if the list is empty; otherwise, it returns false. The missing code is ____.

A) protected
B) int
C) void
D) bool
Question
template
____ doublyLinkedList::isEmptyList() const
{
return (first == NULL);
}
Consider the statements above. The list is empty if the pointer first is ____.

A) NULL
B) 0
C) last
D) next
Question
How many pointers are needed to build a linked list in a backward manner?

A) One
B) Two
C) Three
D) Four
Question
Which of the following correctly initializes a doubly linked list in the default constructor?

A) head = NULL;
Back = NULL;
B) head = 0;
Back = 0;
Count = 0;
C) first = 0;
Last = 0;
D) first = NULL;
Last = NULL;
Count = 0;
Question
The ____ deallocates the memory occupied by the nodes of a list when the class object goes out of scope.

A) constructor
B) destructor
C) head pointer
D) tail pointer
Question
Consider the following code: template
Int doublyLinkedList::length() const
{
____
}
The statement that provides the length of the linked list is ____.

A) cout <<< count;
B) destroy();
C) return count;
D) return next;
Question
The steps involved in inserting a new item at the beginning of an unordered linked list are ____.

A) 1. Create a new node. 2. Insert the node before first.
3) Increment the counter by 1.
B) 1. Create a new node. 2. Store the new item in the new node.
3) Insert the node before first.
4) Increment the counter by 1.
C) 1. Create a new node. 2. Store the new item in the new node.
3) Insert the node before first.
D) 1. Create a new node. 2. Store the new item in the new node.
3) Insert the node before first.
4) Decrement the counter by 1.
Question
Which of the following is a basic operation on singly linked lists?

A) Retrieve the data of an arbitrary node.
B) Swap the head and the last nodes.
C) Determine whether the list is full.
D) Make a copy of the linked list.
Question
Every node in a doubly linked list has two pointers: ____ and ____.

A) previous; next
B) back; next
C) current; next
D) previous; current
Question
The ____________________ operator advances the iterator to the next node in the linked list.
Question
When building a linked list in the ____ manner, a new node is always inserted at the end of the linked list.

A) backward
B) forward
C) traversal
D) random
Question
In a linked list, the link component of each node is a(n) ____________________.
Question
In C++, the dereferencing operator is ____________________.
Question
struct nodeType
{
int info;
nodeType *link;
};
nodeType *head, *p, *q, *newNode;
newNode = new nodeType;
Consider the accompanying code. What is the effect of the following statement? newNode->info = 50;

A) Stores 50 in the info field of the newNode
B) Creates a new node
C) Places the node at location 50
D) Cannot be determined from this code
Question
What is the output of the following program segment? (The class unorderedLinkedList is as defined in the book.) unorderedLinkedList list;
List.insertFirst(6);
List.insertLast(5);
List.insertFirst(4);
List.insertFirst(8);
List.insertLast(10);
List.deleteNode(4);
List.insertFirst(1);
List.print();

A) 1 6 5 8 10
B) 1 6 8 10 5
C) 1 8 6 5 10
D) 1 8 10 6 5
Question
The deleteNode operation (if the item to be deleted is in a doubly linked list) requires the adjustment of ____ pointer(s) in certain nodes.

A) one
B) two
C) three
D) four
Question
In a linked list, the ____________________ operator returns the info of the current node.
Question
A linked list must be searched ____________________, starting from the first node.
Question
The ____________________ constructor executes when an object is declared and initialized using another object.
Question
In a circular linked list with more than one node, it is convenient to make the pointer first point to the ____________________ node of the list.
Question
A linked list in which the last node points to the first node is called a(n) ____________________ linked list.
Question
For classes that include pointer data members, the assignment operator must be explicitly ____________________.
Question
The ____________________ constructor can make an identical copy of a linked list.
Question
The nodes of an ordered list are in ____________________ order.
Question
A(n) ____________________ linked list is a linked list in which every node has a next pointer and a back pointer.
Question
If a formal parameter is a value parameter, the ____________________ constructor provides the formal parameter with its own copy of the data.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 17: Linked Lists
1
A doubly linked list can be traversed in either direction.
True
2
Data can be organized and processed sequentially using an array, called a(n) ____ list.

A) linked
B) ordered
C) sequential
D) ascending
C
3
It is not possible to create an ordered linked list.
False
4
In a linked list, the order of the nodes is determined by the address, called the ____, stored in each node.

A) head
B) tail
C) link
D) first
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
When you build a linked list in the backward manner, a new node is always inserted at the end of the linked list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
A linked list is a collection of components, called ____.

A) elements
B) nodes
C) members
D) pointers
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
Suppose that the pointer head points to the first node in the list, and the link of the last node is NULL. The first node of the linked list contains the address of the ____ node.

A) head
B) first
C) second
D) tail
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
You can use the pointer head of a linked list to traverse the list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
A linked list is a random access data structure.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
Memory for the components of an array does not need to be contiguous.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
What is the purpose of the following code? current = head;
While (current != NULL)
{
//Process current
Current = current->link;
}

A) Insertion of a node
B) Selection of a node
C) Traversal of a linked list
D) Creation of a new list
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
Linked lists allow you to overcome the size limitations of an array data type.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
In a linked list, if a new item is always inserted at the beginning or at the end of the list and the data we read is unsorted, the linked list will be unsorted.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
We deallocate the memory for a linked list by calling the operator clear.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
The link field of the last node of a linked list is ____.

A) NULL
B) 1
C) n-1
D) n
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
Each node of a singly linked list has two components: ____ and ____.

A) info, head
B) link, back
C) back, head
D) info, link
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
Because each node of a linked list has two components, we need to declare each node as a(n) ____.

A) reference and string
B) int and object
C) index and element
D) class or struct
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
In a linked list, the address of the first node in the list is stored in a separate location, called the ____ or first.

A) head
B) pointer
C) front
D) top
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
The length of a linked list is the number of nodes in the list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
Every node (except of the last node) in a singly linked list contains ____.

A) the next node
B) no address information
C) the address of the next node
D) the address of the previous node
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following statements appears in the insert function of a doubly linked list?

A) current++;
B) trailCurrent++;
C) newNode++;
D) count++;
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
Consider the following code which deletes all the nodes in a linked list. void doublyLinkedList::destroy()
{
NodeType *temp; //pointer to delete the node
While (first != NULL)
{
Temp = first;
First = first->next;
____
}
Last = NULL;
Count = 0;
}
Which of the following is the missing statement?

A) delete first;
B) delete temp;
C) destroy temp;
D) clear temp;
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
Each node of a linked list must store the data as well as the ____________________ for the next node in the list
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
A(n) ____________________ is an object that produces each element of a container, such as a linked list, one element at a time.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
template
____ doublyLinkedList::isEmptyList() const
{
return (first == NULL);
}
Consider the statements above. The operation returns true if the list is empty; otherwise, it returns false. The missing code is ____.

A) protected
B) int
C) void
D) bool
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
template
____ doublyLinkedList::isEmptyList() const
{
return (first == NULL);
}
Consider the statements above. The list is empty if the pointer first is ____.

A) NULL
B) 0
C) last
D) next
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
How many pointers are needed to build a linked list in a backward manner?

A) One
B) Two
C) Three
D) Four
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
Which of the following correctly initializes a doubly linked list in the default constructor?

A) head = NULL;
Back = NULL;
B) head = 0;
Back = 0;
Count = 0;
C) first = 0;
Last = 0;
D) first = NULL;
Last = NULL;
Count = 0;
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
The ____ deallocates the memory occupied by the nodes of a list when the class object goes out of scope.

A) constructor
B) destructor
C) head pointer
D) tail pointer
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
Consider the following code: template
Int doublyLinkedList::length() const
{
____
}
The statement that provides the length of the linked list is ____.

A) cout <<< count;
B) destroy();
C) return count;
D) return next;
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
The steps involved in inserting a new item at the beginning of an unordered linked list are ____.

A) 1. Create a new node. 2. Insert the node before first.
3) Increment the counter by 1.
B) 1. Create a new node. 2. Store the new item in the new node.
3) Insert the node before first.
4) Increment the counter by 1.
C) 1. Create a new node. 2. Store the new item in the new node.
3) Insert the node before first.
D) 1. Create a new node. 2. Store the new item in the new node.
3) Insert the node before first.
4) Decrement the counter by 1.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
Which of the following is a basic operation on singly linked lists?

A) Retrieve the data of an arbitrary node.
B) Swap the head and the last nodes.
C) Determine whether the list is full.
D) Make a copy of the linked list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
Every node in a doubly linked list has two pointers: ____ and ____.

A) previous; next
B) back; next
C) current; next
D) previous; current
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
The ____________________ operator advances the iterator to the next node in the linked list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
When building a linked list in the ____ manner, a new node is always inserted at the end of the linked list.

A) backward
B) forward
C) traversal
D) random
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
In a linked list, the link component of each node is a(n) ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
In C++, the dereferencing operator is ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
struct nodeType
{
int info;
nodeType *link;
};
nodeType *head, *p, *q, *newNode;
newNode = new nodeType;
Consider the accompanying code. What is the effect of the following statement? newNode->info = 50;

A) Stores 50 in the info field of the newNode
B) Creates a new node
C) Places the node at location 50
D) Cannot be determined from this code
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
What is the output of the following program segment? (The class unorderedLinkedList is as defined in the book.) unorderedLinkedList list;
List.insertFirst(6);
List.insertLast(5);
List.insertFirst(4);
List.insertFirst(8);
List.insertLast(10);
List.deleteNode(4);
List.insertFirst(1);
List.print();

A) 1 6 5 8 10
B) 1 6 8 10 5
C) 1 8 6 5 10
D) 1 8 10 6 5
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
The deleteNode operation (if the item to be deleted is in a doubly linked list) requires the adjustment of ____ pointer(s) in certain nodes.

A) one
B) two
C) three
D) four
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
In a linked list, the ____________________ operator returns the info of the current node.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
A linked list must be searched ____________________, starting from the first node.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
The ____________________ constructor executes when an object is declared and initialized using another object.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
In a circular linked list with more than one node, it is convenient to make the pointer first point to the ____________________ node of the list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
A linked list in which the last node points to the first node is called a(n) ____________________ linked list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
For classes that include pointer data members, the assignment operator must be explicitly ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
The ____________________ constructor can make an identical copy of a linked list.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
The nodes of an ordered list are in ____________________ order.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
A(n) ____________________ linked list is a linked list in which every node has a next pointer and a back pointer.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
If a formal parameter is a value parameter, the ____________________ constructor provides the formal parameter with its own copy of the data.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 50 flashcards in this deck.