Question: C++ Help. 1) When building a linked list forward, which of the following statement(s) correctly inserts the first node, called newNode into a nonempty list?

C++ Help.

1) When building a linked list forward, which of the following statement(s) correctly inserts the first node, called newNode into a nonempty list? Assume that you have two pointer variables, first and last, that are initialized to NULL, and that newNode has been initialized with data and a link value of NULL.

a)first = newNode; last = newNode;

b)last = newNode;

c)last->link = newNode; last = newNode;

d)first->link = newNode;

2)You can use ____ to traverse a list.

a)a pointer variable set to the same value as head

b)the head pointer of a linked list

c)a pointer variable set to the pointer value of the last node in the list

d)any pointer in a linked list

3)Which of the following sets of statements will correctly delete the node from a linked list that q is pointing to, assuming that p is pointing to the node before it?

a)q->link = p; p->link = q->link; delete q;

b)q->link = p->link; p->link = q; delete q;

c)q = p->link; p->link = q; delete q;

d)q = p->link; p->link = q->link; delete q;

4)

Because the links to the nodes of an ordered list are only in one direction, an effective way to print the list in reverse order is to use _____.

a)recursion

b)a pointer to the last node

c)a search algorithm

d)duplication

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!