CS Chapter 16

Ace your homework & exams now with Quizwiz!

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

c. second

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

c. sequential

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

c. the address of the next node

A linked list in which the last node points to the first node is called a(n) ________ linked list.

circular

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

Overloaded

A linked list is a random access data strcutre

False

It is not possible to create an ordered linked list

False

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

False

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

False

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

False

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

False

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

pointer

In C++, the dereferencing operator is represented b the _____ symbol.

*

A doubly linked list can be traversed in either direction

True

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

True

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

True

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

True

Consider the accompanying statements. The list is empty if the pointer first is _____. a. NULL b. 0 c. last d. next

a. NULL

The link field of the last node of a linked list is _______ a. NULL b. 1 c. n-1 d. n

a. NULL

In a linked list, the address of the first node in the list is sorted in a separate location, called the _____ or first. a. head b. pointer c. front d. top

a. head

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

a. stores 50 in the info field of the newNode

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

address

The nodes of a standard ordered list ( as constructed in the text) are in _______ order.

ascending

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 new node before first 4. Decrement 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

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

b. Two

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

b. back; next

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;

b. delete temp;

The ____ decollates 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. destructor

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

b. forward

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

b. nodes

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

b. two

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. 1 8 6 5 10

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

c. Traversal of a linked list

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. link

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

c. return count;

If a formal parameter is a value parameter, the _____ constructor provides the formal parameter with its own copy of the data.

copy

The _____ constructor can make an identical copy of a linked list.

copy

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

copy

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

d. Make a copy of the linked list

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

d. bool

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

d. class or struct

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

d. count++;

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. first = NULL; last = NULL; count = 0;

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

d. info, link

In a linked list, the ________ operator returns the info of the current node.

dereferenceing

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

doubly

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

icrement

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

iterator

In a circular linked list with more than one node, it is convenient to make the pointer first point to the ____node of the list.

last

A linked list must be searched ______, starting from the first node.

sequentially


Related study sets

AP Psychology Chapter 8: Development Across the Life Span

View Set

Learning 2.6 : Compare and contrast common computing devices and their purposes

View Set

Differential Reinforcement (RBT)

View Set

Chapter 5: Greek City States Study Guide

View Set

The Client with Urinary Tract infection

View Set