KRHS Internet Lesson

Teacher Name:Mr. Rung                          Date of Lesson: April/May

Course Name: C++                    Lesson Name: Chap 16.1.2.3b

Student Name

Password


Objective
To finish the completion exercises in the workbook.


Primary Focus
Match the colums below.

Site Links
Course Home Page

Additional Resources

Site Links


How can you tell if an error occurred while allocating memory?
Adelete MyRecordPointer;
What is the heap?
BA null value in the next pointer of the last node.
Describe a program that might benefit from a linked list.
CA pointer to the next node.
What signals the end of a linked list?
DMYRecordPointer = new student-record;
What is the most common reason for unsuccessful allocation when using the new operator?
EThe memory left over after your operating system and programs are loaded.
In addition to the data you want to store in the linked list, what must each node store?
F if (MyRecordPointer 1= NULL)
{ cout « "Allocation successful.\n"; } else
{ cout « "Memory allocation errorl\n"; } 10. delete MyRecordPointer;
What is the name of the pointer that points to the first node in a linked list?
GA program that adds and deletes data frequently.
Write a statement that will allocate memory on the heap for a structure named Btudent-record. Assign the address of the allocated memory to a pointer called MyRecordPointer
HThe head pointer.
Write the code necessary to check for errors in the memory allocation in question 8 above. Your code should display a message indicating that the memory allocation was successful or unsuccessful.
ITest the pointer that the new operator was supposed to create. If it is equal to NULL, there was an allocation error.
Write a statement that deallocates the memory allocated in question 8.
JInsufficient free RAM to satisfy your request.
Assume a linked list exists and that a pointer named head ptr points to the first node of the list. Within each node is a pointer named next which points to the next node in the list. Write a statement that will assign the address of the first node in the list to a pointer named traversing ptr.
Knodes D, E, and F would become inaccessible.
Write a loop that will traverse the linked list described in question 1 above using the pointer named traversing-ptr, which currently points to the head of the list. The loop should iterate until all nodes have been visited. When the loop stops iterating, traversing-ptr should hold the address of the last node in the list.
LNode E would become inaccesible.
If head-ptr were assigned a null pointer, how would the operation of the linked list be affected?
Mwhile(traversing-ptr.next 1= NULL)
{traversing-ptr = traversing-ptr.next; }
Ifhead-ptr were made to point to node B rather thanA, how would nodeAbe accessed?
NAny traversal would loop infinitely at the end of the list because a null pointer would not be reached.
If the next pointer in node C were assigned a null pointer, how would nodes D, E, and F be affected?
Otraversing-ptr = head-ptr;
If the next pointer in node D were made to point to node F rather than node E, how would node E be affected?
PA could no longer be accessed.
If the next pointer in node E were made to point to node E (itself), what would happen when the list is traversed?
QThe entire list would be lost because you could not find the first node.