Professional Documents
Culture Documents
Lab. Sheet One: Linear List
Lab. Sheet One: Linear List
Sheet One
Linear List
#include<iostream>
using namespace std;
template <class T>
class LinearList{
int length;
int maxsize;
T *element;
public:
LinearList(int maxlistsize=10);
~LinearList() { delete [ ]element; }
int Length() { return length; }
bool Isempty() { return (length==0); }
bool Find(int, T&);
int Search(T);
LinearList<T>& Delete(int, T&);
void Sort_Insert(T);
void Insert(int, T);
void output( ); };
void main( )
{
// write here code that will test the LinearList class
functions
}
Lab Exercise:
Note: add any other functions that your program may need.
Exercises:
1. Add to (LinearList class) function modify that will modify the value for
specific element.
2. Add to (LinearList class) function Sorted_inseart that will insert elements to
the class with sorted order.
3. (Line and letter count) using “LinearList class functions” write a program
that reads a given text, outputs the text as it is, and also prints the number of
times each letter appears in the text. An uppercase letter and a lowercase letter
are treated as being the same. Because there are 26 letters, we use an array of
26 components to perform the letter count.