C++ Linked List

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/31

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

32 Terms

1
New cards

False

A list that contains pointers to the previous node, the next node, and a node in the third dimension is known as a triple linked list.

Group of answer choices

True/False

2
New cards

arranged in ascending order

To insert a new node in ascending order into a list, the list must be

Group of answer choices

arranged in descending order

randomly ordered

empty

arranged in ascending order

None of these

3
New cards

copy

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

4
New cards

it encounters a null pointer

While traversing a list, a node pointer knows when it has reached the end of the list if

Group of answer choices

it encounters the newline character

it encounters a null pointer

it finds itself back at the beginning of the list

it encounters a sentinel such as 9999

5
New cards

there are no nodes in the list

If the head pointer points to nullptr, this indicates

Group of answer choices

the list has been previously created and then destroyed

the list needs to be destroyed

there are no nodes in the list

the list is full and cannot accept any new nodes

None of these

6
New cards

head

In a linked list, the address of the first node in the list is stored in a separate location, called the ____ or first.

Group of answer choices

head

pointer

front

top

7
New cards

a node can be inserted or removed faster from a linked list than from a vector

The advantage a linked list has over a vector is that

Group of answer choices

a linked list can dynamically shrink or grow and a vector cannot

a linked list is smaller than a vector

a node can be inserted or removed faster from a linked list than from a vector

data removal and insertion are more accurate with a linked list than with a vector

None of these

8
New cards

True

When you delete a node from a list, you must ensure that the links in the list are not permanently broken.

Group of answer choices

True/False

9
New cards

first = nullptr;

last = nullptr;

count = 0;

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

Group of answer choices

head = nullptr;

back = nullptr;

head = 0;

back = 0;

count = 0;

first = 0;

last = 0;

first = nullptr;

last = nullptr;

count = 0;

10
New cards

doubly

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

11
New cards

Stores 50 in the info field of the newNode

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;

Group of answer choices

Stores 50 in the info field of the newNode

Creates a new node

Places the node at location 50

Cannot be determined from this code

12
New cards

False

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

Group of answer choices

True/False

13
New cards

two: remove the node without breaking links, then delete it from memory

How many steps are involved in the process of deleting a node?

Group of answer choices

one: delete the node from memory

two: remove the node without breaking links, then delete it from memory

three: create a blank node, remove the node being deleted, insert the blank node

four: create a blank node, insert the blank node before the node being deleted, remove the node being deleted, delete the blank node

None of these

14
New cards

nullptr

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

Group of answer choices

nullptr

1

n-1

n

15
New cards

first = nullptr;

last = nullptr;

count = 0;

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

Group of answer choices

head = nullptr;

back = nullptr;

head = 0;

back = 0;

count = 0;

first = 0;

last = 0;

first = nullptr;

last = nullptr;

count = 0;

16
New cards

inserting

Appending a node means adding it to the end of a list, and ________ a node means putting a new node in the list, but not necessarily at the end.

Group of answer choices

concatenating

popping

clamping

inserting

None of these

17
New cards

circular linked

Which type of list does NOT contain a null pointer at the end of the list?

Group of answer choices

backwards linked

doubly linked

circular linked

null linked

None of these

18
New cards

head

The ________ of a linked list points to the first node in the list.

Group of answer choices

starter

head

tail

declaration

None of these

19
New cards

two: one for the node under inspection and one for the previous node

In an insertion or deletion routine: how many pointers are you required to create for use during the traversal process?

Group of answer choices

two: one for the node under inspection and one for the previous node

two: one for the node under inspection and one for the next node

one: for the node being inserted or deleted

three: one for the node under inspection, one for the next node, and one for the following node

20
New cards

Traversal of a linked list

What is the purpose of the following code?

current = head;

while (current != nullptr)

{

//Process current

current = current->link;}

Group of answer choices

Insertion of a node

Selection of a node

Traversal of a linked list

Creation of a new list

21
New cards

False

We deallocate the memory for a linked list by calling the operator clear.

Group of answer choices

True/False

22
New cards

True

To delete an entire list, normally you must traverse the list, deleting each node, one by one.

Group of answer choices

True/False

23
New cards

back; next

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

Group of answer choices

top; bottom

back; next

current; forward

previous; forward

24
New cards

the previous node

A doubly linked list keeps track of the next node in the list as well as

Group of answer choices

itself

the head node

the tail node

the previous node

None of these

25
New cards

the destructor function

A linked list class must take care of removing the dynamically allocated nodes and this is done by

Group of answer choices

the constructor function

the destructor function

overriding the removal function

overloading the memory persistence operator

None of these

26
New cards

first node

In a circular linked list, the last node points to the

Group of answer choices

head pointer

tail pointer

first node

None of these

27
New cards

True

When working with a linked list one of the basic operations you can perform is to destroy the list.

Group of answer choices

True/False

28
New cards

Make a copy of the linked list.

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

Group of answer choices

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.

29
New cards

sequential

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

Group of answer choices

linked

ordered

sequential

ascending

30
New cards

doubly linked list

The list container provided by the Standard Template Library is a template version of a

Group of answer choices

singly linked list

doubly linked list

circular linked list

backward linked list

None of these

31
New cards

doubly

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

32
New cards

class or struct

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

Group of answer choices

reference and string

int and object

index and element

class or struct