1. You are asked to design a function that removes duplicates from a
singly linked list. In plain English describe how you could break this
problem down into simpler subtasks before writing code.
2. The definition of the ‘new’ operator
3. Which XXX will avoid a memory leak:
#include <iostream>
Using namespace std;
Class myClass{
Public:
myClass();
int value;
private:
int* ptr;
};
myClass::myClass(){
ptr = new int;
*ptr = 0;
Delete ptr;
}
Int main(){
Int value = 100;
Int* ptr = new int;
///XXX
Ptr1 = &value;
4. Which statement properly frees the dynamically allocated array below:
a. Musketeer* musketeers = new Musketeer[8];
5. You have the following doubly-linked list. Each node has a data(char),
as well as prev and next Node pointers. Create a new Node with the
value ‘z’ and replace thisNode with your new Node. For this exercise,
you will not overwrite thisNode’s data. Instead, you will connect your
singly linked list. In plain English describe how you could break this
problem down into simpler subtasks before writing code.
2. The definition of the ‘new’ operator
3. Which XXX will avoid a memory leak:
#include <iostream>
Using namespace std;
Class myClass{
Public:
myClass();
int value;
private:
int* ptr;
};
myClass::myClass(){
ptr = new int;
*ptr = 0;
Delete ptr;
}
Int main(){
Int value = 100;
Int* ptr = new int;
///XXX
Ptr1 = &value;
4. Which statement properly frees the dynamically allocated array below:
a. Musketeer* musketeers = new Musketeer[8];
5. You have the following doubly-linked list. Each node has a data(char),
as well as prev and next Node pointers. Create a new Node with the
value ‘z’ and replace thisNode with your new Node. For this exercise,
you will not overwrite thisNode’s data. Instead, you will connect your