Chapter 6 linked list

Ace your homework & exams now with Quizwiz!

What is different in a doubly linked list?

Every node has 2 links, one points to the next node and one to the previous node

(T/F) A linked list is a random access data structure.

F

(T/F) It is not possible to create an ordered linked list.

F

(T/F) Memory for the components of an array does not need to be contiguous.

F

(T/F) We deallocate the memory for a linked list by calling the operator clear.

F

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

F

(T/F) You can use the pointer head of a linked list to traverse the list.

F

(T/F) You deallocate the memory for a linked list by calling the operator clear.

F

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

Head

Where is the pointer to a linked list stored?

In a separate location called the head or first

What is the output of the following program segment? (The class unorderedLinkedList is as defined in the book.) unorderedLinkedList<int> 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

1 8 6 5 10

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

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.

How many pointers have to be adjusted if you insert or delete in a doubly linked list?

2 pointers in the node

A doubly linked list can be traversed ____________

In either direction

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

Link

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.

Make a copy of the linked list.

When items are inserted or deleted from a linked list does it require data movement?

No, only the pointer are adjusted

A linked list is a collection of components called ____. a. elements b. nodes c. members d. pointers

Nodes

A linked list is a list of items, called _______, in which the order of the nodes is determined by the address, called a link, stored in each node

Nodes

A single linked list is traversed in how many directions?

One

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 b. tail c. first d. head

Second

Data can be organized and processed sequentially using an array called a(n) ____ list. a. linked b. ordered c. sequential d. ascending

Sequential

The search on a linked list is ___________

Sequential

How many pointers are needed to build a linked list in a backward manner? a. One b. Two c. Three d. Four

Two

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

Two

To traverse a linked list what does the program have to do?

Use a pointer different than the head pointer of the list which is initialized to the first node

A doubly linked list can be traversed in which direction

Either direction

The link field of the last node of a linked list is ____. a. nullptr (NULL) b. 1 c. n-1 d. n

nullptr (NULL)

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

second

template <class Type> ____ doublyLinkedList<Type>::isEmptyList() const { return (first == NULL); } Consider the accompanying statements. 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

Bool

What is a linked list in which the last node points to the first node called?

Circular linked list

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

Class or struct

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

Stores 50 in the info field of the newNode

(T/F) A doubly linked list can be traversed in either direction.

T

(T/F) In a linked list, if a new item is always inserted at the beginning or at the end of the list and the data read is unsorted, the linked list will be unsorted.

T

(T/F) 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.

T

(T/F) Linked lists allow you to overcome the size limitations of an array data type.

T

(T/F) The length of a linked list is the number of nodes in the list.

T

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

The address of the next node

What is the length of a linked list?

The number of nodes in the list

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

Traversal of a linked list

Every node in a doubly linked list has two pointers: ____ and ____. a. previous; next b. back; next c. current; next d. previous; current

back; next

Which of the following statements appears in the insert function of a doubly linked list? a. current++; b. trailCurrent++; c. newNode++; d. count++;

count++;

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

destructor

A linked list is a ___________

dynamic data structure

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;

first = NULL;last = NULL;count = 0;

The first , or head, pointer of a linked list is always what?

fixed, pointing to the first node in the list

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

forward

Each node of a singly linked list has two components: ____ and ____. a. info, head b. link, back c. back, head d. info, link

info, link


Related study sets

week 9 Pharmacology (ATI) Musculoskeletal System

View Set

OB _ Practice HESI Exam _ Gestational Diabetes _ Case Study _ 2023

View Set

Review (Ratio, Rates, Percentages)

View Set

Art 206 (Chap 1 Unit Exam 1 Prep)

View Set

Lippincott NCLEX Review - Addison's Disease

View Set

Structure and Functions of Government

View Set