Questions: Answer the following questions using your Laptop computer.
1. Declare a node named nodeType as a struct type which contains two components (int type Data and nodeType *NextPtr) and a variable named Head that point to the nodeType.
2. What does the following do for a given Linked List?
Assume the structure of a Linked list node is as follows:
a. print node information
int main ( ) {
nodeType *head, *curr;
head = buildListForward( ); //Assume node is created by calling this function
while( )
{
}
return 0;
}
b. What does the following do for a given Linked List?
void func_recursive(struct nodeType* head)
{
if(head == NULL)
return;
func_recursive(head->nextPtr);
cout << head->Data);
}
c. Trace the reverse order traversal (Draw the flow):
3. Consider the linked list shown as below, What is the output, if any, of each of the following C++ Statement.
a. cout << current -> info;
b. current = current->link;
cout << current->info;
c. cout << temp->link->link->info;
d. trail->link = NULL;
cout << trail->info;
e. cout << last -> link -> info;
4. What is the value of each of the following relational expressions(true/false) ?
a. current-> link = = temp;
b. temp-> link -> link -> info = = 50;
c. trail -> link -> link = = 0;
d. last -> link == NULL;
e. list == current;
5. Write C++ statement to do the following:
a. set the info of the second node to 52.
b. make current point to the node with info 10.
c. Make trail point to the node before temp.
d. Make temp point to an empty list.
e. set the value of the node before trail to 36.
f. write a while loop to make current point to the node with info 10.
6. Write C++ Statements to do the following:
a. Write a C++ code so that current traverses the entire list.
b. Create the node with info 68 and insert it between trail and last.
c. Delete the last node of the list and also allocate the memory occupied by this node.
After deleting this node, make last point to the last node of the list and the link of the
last node must be NULL.
d. Delete the node with info 10. Also, deallocate the memory occupied by this node.
Page 4 of 4