1.Mark the following statements as true or false.

(a)A class containing one or more pure virtual functions is an abstract class.

(b)In a linked list, memory allocated for the nodes is sequential.

(c)A linked list is a random access data structure.

(d)The head pointer of a linked list cannot be used to traverse the list.

(e)In a linked list, nodes are always inserted either at the beginning or the end because a linked list is not a random access data structure.

2.Consider the linked list shown in the following figure. Assume that the nodes are in the usual info-next form. Use this list to answer Problems 2 through 6. If necessary, declare additional variables. (Assume that list, p, s, A, and B are pointers of type NodeType.) see image.

What is the output of each of the following C++ statements?

(a)cout << list->info;

(b)cout << A->info;

(c)cout << B->next->info;

(d)cout << list->next->next->info;

3.What is the value of each of the following relational expressions? (Use the list shown in Problem 2.)

(a)list->info >= 18

(b)list->next == A

(c)A->next->info == 16

(d)B->next == NULL

(e)list->info == 18

4.Mark each of the following statements as valid or invalid. If a statement is invalid, explain why. (Use the list shown in Problem 2.)

(a)A = B;

(b)list->next = A->next;

(c)list->next->info = 45;

(d)*list = B;

(e)*A = *B;

(f)B = A->next->info;

(g)A->info = B->info;

(h)list = B->next->next;

(i)B = B->next->next->next;

5.Write C++ statements to do the following. (Use the list shown in Problem 2.)

(a)Make A point to the node containing info 23.

(b)Make list point to the node containing 16.

(c)Make B point to the last node in the list.

(d)Make list point to an empty list.

(e)Set the value of the node containing 25 to 35.

(f)Create and insert the node with info 10 after the node pointed to by A.

(g)Delete the node with info 23. Also, deallocate the memory occupied by this node.

6.What output do you expect for the following C++ code (without actually executing the program in Visual C++)? (Use the list shown in Problem 2.)

p = list;

while (p != NULL)
{
cout << p->info << " ";
p = p->next;
}
cout << endl;

7.Show what is expected to be produced by the following C++ code (without actually executing the program in Visual C++). Assume the code is in the usual info-next form with the info of type int. (list and ptr are pointers of type NodeType.)

(a) list = new NodeType;
list->info = 10;
ptr = new NodeType;
ptr->info = 13;
ptr->next = NULL;
list->next = ptr;
ptr = new NodeType;
ptr->info = 18;
ptr->next = list->next;
list->next = ptr;
cout << list->info << " " << ptr->info << " ";
ptr = ptr->next;
cout << ptr->info << endl;
(b) list = new NodeType;
list->info = 20;
ptr = new NodeType;
ptr->info = 28;
ptr->next = NULL;
list->next = ptr;
ptr = new NodeType;
ptr->info = 30;
ptr->next = list;
list = ptr;
ptr = new NodeType;
ptr->info = 42;
ptr->next = list->next;
list->next = ptr;
ptr = list;
while (ptr != NULL)
{
cout << ptr->info << endl;
ptr = ptr->next;
}

8.Use the UnsortedLinkedList class given to you in Week 6 Day 3 Example Programs. What output do you expect for the following program segment (without actually executing the program in Visual C++)?

UnsortedLinkedList< int> list;

list.insert(15);
list.insert(28);
list.insert(30);
list.insert(2);
list.insert(45);
list.remove(30);
list.insert(18);
list.remove(28);
list.remove(12);
list.printList();

9. Use the UnsortedLinkedList class given to you in Week 6 Day 3 Example Programs. Suppose the input is

16 30 4 32 45 32 78 19 48 75 -999

What output do you expect for the following program segment (without actually executing the program in Visual C++)?

UnsortedLinkedList< int> list;
UnsortedLinkedList< int> copyList;
int num;

cin >> num;
while (num != -999)
{
if (num % 5 != 3)
list.insert(num);
cin >> num;
}

list.printList();
cout << endl;

copyList = list;

copyList.remove(78);
copyList.remove(32);

cout << "Copy List = ";
copyList.printList();
cout << endl;

10.Use the SortedLinkedList class given to you in Week 6 Day 3 Example Programs. What output do you expect for the following program segment (without actually executing the program in Visual C++)?

SortedLinkedList< int> list;

list.insert(15);
list.insert(28);
list.insert(30);
list.insert(2);
list.insert(45);
list.remove(30);
list.insert(18);
list.remove(28);
list.remove(12);
list.printList();

11. Use the SortedLinkedList class given to you in Week 6 Day 3 Example Programs. Suppose the input is

16 30 4 32 45 32 78 19 48 75 -999

What output do you expect for the following program segment (without actually executing the program in Visual C++)?

SortedLinkedList< int> list;
SortedLinkedList< int> copyList;
int num;

cin >> num;
while (num != -999)
{
if (num % 5 != 3)
list.insert(num);
cin >> num;
}

list.printList();
cout << endl;

copyList = list;

copyList.remove(78);
copyList.remove(32);

cout << "Copy List = ";
copyList.printList();
cout << endl;
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.