Professional Documents
Culture Documents
Assignment 6 - Csit221
Assignment 6 - Csit221
Please submit the code for each problem on onCourse in a single text file. In addition, a printed copy of the assignment
(in a readable format) is due at the beginning of the class on the due date.
Problems 1 and 2. Consider the linked list we implemented in class
template <class T>
struct nodeType
{
T data;
nodeType<T> *next;
};
int numPosElements();
//returns the number of elements for which the field data>0
//note this will only work for those list that the comparison data>0 is defined
private:
nodeType<T>* head;
int size;
};
Problem 1 (20 points) Implement the function split for the class above.
Problem 2 (20 points) Implement the function numPosElement for the class above.
Problem 3 (20 points) Write a piece of code that given an STL (standard template library) stack of doubles, it will remove
the negative entries from the stack. The order of the remaining entries must be preserved.
Problem 4 (20 points) Write a piece of code that given an STL queue of strings, it will remove the strings that start with a
digit (0-9) from the queue. The order of the remaining entries must be preserved.
Problem 5 (20 points) Write a function that will test if the contents of an STL queue of characters form a palindrome. A
palindrome is a string that reads the same forward and backward (e.g. kayak, madam, dad).