Unlock access to all the studying documents.
View Full Document
Copyright Cengage Learning. Powered by Cognero.
1. Linked lists allow you to overcome the size limitations of an array data type.
2. Memory for the components of an array does not need to be contiguous.
3. You can use the pointer head of a linked list to traverse the list.
4. We deallocate the memory for a linked list by calling the operator clear.
Copyright Cengage Learning. Powered by Cognero.
5. 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.
6. When you build a linked list in the backward manner, a new node is always inserted at the end of the linked list.
7. It is not possible to create an ordered linked list.
8. The length of a linked list is the number of nodes in the list.
b.
Creates a new node
c.
Places the node at location 50
d.
Cannot be determined from this code
ANSWER:
POINTS:
1
REFERENCES:
1121
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
PREFACE NAME:
nodeType
DATE CREATED:
10/5/2016 1:43 PM
DATE MODIFIED:
10/5/2016 1:43 PM
a.
backward
b.
forward
current = head;
while (current != nullptr)
{
//Process current
current = current–>link;
}
Traversal of a linked list
Copyright Cengage Learning. Powered by Cognero.
23. How many pointers are needed to build a linked list in a backward manner?
24. Which of the following is a basic operation on singly linked lists?
Retrieve the data of an arbitrary node.
Swap the head and the last nodes.
Determine whether the list is nearly full.
Make a copy of the linked list.
25. The ____ deallocates the memory occupied by the nodes of a list when the class object goes out of scope.
Copyright Cengage Learning. Powered by Cognero.
26. The steps involved in inserting a new item at the beginning of an unordered linked list are ____.
1. Create a new node.
2. Insert the node before first.
3. Increment the counter by 1.
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.
1. Create a new node.
2. Store the new item in the new node.
3. Insert the node before first.
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.
27. Every node in a doubly linked list has two pointers: ____ and ____.
28. Which of the following correctly initializes a doubly linked list in the default constructor?
head = nullptr;
back = nullptr;
head = 0;
back = 0;
count = 0;
first = nullptr;
last = nullptr;
b.
d.
ANSWER:
d
POINTS:
1
REFERENCES:
1167
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
PREFACE NAME:
isEmpty
DATE CREATED:
10/5/2016 1:43 PM
DATE MODIFIED:
10/5/2016 1:43 PM
b.
d.
ANSWER:
POINTS:
1
REFERENCES:
1167
QUESTION TYPE:
Multiple Choice
HAS VARIABLES:
False
PREFACE NAME:
isEmpty
DATE CREATED:
10/5/2016 1:43 PM
DATE MODIFIED:
10/5/2016 1:43 PM
Copyright Cengage Learning. Powered by Cognero.
____
}
The statement that provides the length of the linked list is ____.
32. Consider the following code which deletes all the nodes in a linked list.
void doublyLinkedList<Type>::destroy()
{
nodeType<Type> *temp; //pointer to delete the node
while (first != nullptr)
{
temp = first;
first = first–>next;
____
}
last = nullptr;
count = 0;
}
Which of the following is the missing statement?
33. Which of the following statements appears in the insert function of a doubly linked list?