The weight of each question is given with the question
Use as much paper as you wish, but make your answers are legible.
Please answer each question thoughtfully and carefully.
[5 points] What is dynamic data and how is it different from static data?
[5 points] What is a memory leak? How can memory leaks be avoided.
[10 points] What does the following code segment do? (Describe what happens at each line, refer to the line numbers in your discussion).
int * a;
int b;
a = & b;
*a = 7;
cout << *a << endl;
[5 points] Give code that prompts the user for an array size, and then
allocates an array of integers that size.
[10 points] Write a routine that takes an array, the size of the array, and replaces it with a new array ten elements larger. All data in the original array should be copied to the new array.
[5 points] What is a deep copy, what is a shallow copy?
Where does this issue become a problem?
[5 points] Create an example where a deep copy is required. Give code segments and data structure declarations.
[5 points] Describe the linked list data structure. Draw
a picture and label the elements.
struct nodeT {
int data;
nodeT * next;
}
[5 points] Write a routine that takes a pointer to a valid list of nodeT (as defined above), and prints the list.
[5 points] Write a routine that takes a pointer to a valid list of nodeT (as defined above), and an element, and adds the element to the list in the first position.
[10 points] Write a routine that takes a pointer to a valid list of nodeT (as defined above), and deletes every other element, starting with the first element in the list.
[30 points] Create list based string class. This class should store
the string in a linked list of characters. You should provide
a class specification and implementation. You should support the
following operations