Chapter 17 Flashcards

1
Q

True or false:
Linked list allow you to overcome the size limitations of an array data type.

A

True

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

True or false:
Memory for the components of an array does not need to be contiguous

A

False

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

True or false:
You can use the pointer head of a linked list to traverse the list.

A

False

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

True or false:
We deallocate the memory for a linked list by calling the operator clear.

A

False

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

True or false:
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.

A

True

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

True or false:
When you build a linked list in the backward manner, a new node is always inserted at the end of the linked list.

A

False

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

True or false:
It is not possible to create an ordered linked list.

A

False

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

True or false:
The length of a linked list is the number of nodes in the list.

A

True

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

True or false:
A linked list is a random access data structure.

A

True

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

True or false:
A doubly linked list can be traversed in either direction.

A

True

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

Data can be organized and processed sequentially using an array, called a(n) ____ list.

A

sequential

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

A linked list is a collection of components, called ____.

A

nodes

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

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

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

In a linked list, the order of the nodes is determined by the address, called the ____, stored in each node.

A

link

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

Every node (except of the last node) in a singly linked list contains ____.

A

the address of the next node

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

The link field of the last node of a linked list is ____.

A

nullptr

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

Because each node of a linked list has two components, we need to declare each node as a(n) ____.

A

class or struct

18
Q

Each node of a singly linked list has two components: ____ and ____.

A

info, link

19
Q

Suppose that the pointer head points to the first node in the list, and the link of the last node is nullptr. The first
node of the linked list contains the address of the ____ node.

A

second

20
Q

What is the purpose of the following code?

current = head;
while (current != nullptr)
{
//Process current
current = current->link;
}

A

Traversal of a linked list

21
Q

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

22
Q

When building a linked list in the ____ manner, a new node is always inserted at the end of the linked list.

A

forward

23
Q

Which of the following is a basic operation on singly linked lists?

A

make a copy of the linked list

24
Q

How many pointers are needed to build a linked list in a backward manner?

A

two

25
Q

The ____ deallocates the memory occupied by the nodes of a list when the class object goes out of scope.

A

destructor

26
Q

The steps involved in inserting a new item at the beginning of an unordered linked list are ____.

A
  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.
27
Q

Every node in a doubly linked list has two pointers: ____ and ____.

A

back, next

28
Q

Which of the following correctly initializes a doubly linked list in the default constructor?

A

first = nullptr;
last = nullptr;
count = 0;

29
Q

template <class>
\_\_\_\_ doublyLinkedList<Type>::isEmptyList() const
{
return (first == nullptr);
}</Type></class>

Consider the accompanying statements. The operation returns true if the list is empty; otherwise, it returns false. The missing code is ___.

A

bool

30
Q

template <class>
\_\_\_\_ doublyLinkedList<Type>::isEmptyList() const
{
return (first == nullptr);
}</Type></class>

Consider the statements above. The list is empty if the pointer first is ____.

A

nullptr

31
Q

Consider the following code:

template <class>
int doublyLinkedList<Type>::length() const
{
\_\_\_\_
}</Type></class>

The statement that provides the length of the linked list is _____.

A

return count;

32
Q

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;
}</Type></Type>

Which of the following is the missing statement?

A

delete temp;

33
Q

Which of the following statements appears in the insert function of a doubly linked list?

A

count++;

34
Q

In a linked list, the link component of each node is a(n) ____________________.

A

pointer

35
Q

Each node of a linked list must store the data as well as the ____________________ of the next node in the list.

A

address

36
Q

In C++, the dereferencing operator is ____.

A

*

37
Q

A(n) ____________________ is an object that produces each element of a container, such as a linked list, one
element at a time.

A

iterator

38
Q

The ____________________ operator advances the iterator to the next node in the linked list.

A

increment (++)

39
Q

For classes that include pointer data members, the assignment operator must be explicitly
____________________.

A

overloaded

40
Q

The ____________________ constructor executes when an object is declared and initialized using another object.

A

copy

41
Q

A(n) ____________________ linked list is a linked list in which every node has a next pointer and a back pointer.

A

doubly