CH 16 CSCI

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

D

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

C

Consider the following code: template <class Type> int doublyLinkedList<Type>::length() const { ____ } The statement that provides the length of the linked list is ____. a. cout <<< count; b. destroy(); c. return count; d. return next;

C

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

D

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

C

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

C

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

B

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

D

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;

D

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.

A

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

D

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

A

template <class Type> ____ doublyLinkedList<Type>::isEmptyList() const { return (first == NULL); } Consider the accompanying statements. The list is empty if the pointer first is ____. a. nullpointer (NULL) b. 0 c. last d. next

B

template <class Type> ____ doublyLinkedList<Type>::isEmptyList() const { return (first == nullptr); } Consider the statements above. The list is empty if the pointer first is ____. a. next b. nullptr c. last d. 0

T

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

F

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

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.

F

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

T

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

F

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

T

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

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.

B

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

D

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

B

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 != 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;

C

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

B

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

B

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

A

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

C

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

C

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

A

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

B

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

B

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 c. three b. two d. four

A

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

B

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.


Set pelajaran terkait

EDPUZZLE #36 World War II Part 2 - The Homefront

View Set

Business Education Content Knowledge

View Set

Entrepreneurship business idea generation an initial evaluation

View Set