Question: modify this implementation file to CList #include LList.h /* Purpose: generic sorted linked list class */ /* implementation file */ /***************************************************************/ template LList :: LList()

 modify this implementation file to CList #include "LList.h" /* Purpose: generic

modify this implementation file to CList

#include "LList.h"

/* Purpose: generic sorted linked list class */ /* implementation file */ /***************************************************************/

template LList :: LList() { first = NULL; }

template LList :: ~LList() { destroy(); }

template LList :: LList ( const LList & other) { copy(other); }

template const LList & LList :: operator= (const LList & other) { if ( this != &other ) { destroy(); copy(other); }

return *this; }

template bool LList :: isEmpty() { return first == NULL; }

/* template void LList :: insertItem(T item) { node *temp;

temp = new node; temp->info = item;

if ( first == NULL || item info ) { temp->next = first; first = temp; }

else { node *r = first; node *p = first->next;

while ( p != NULL && p->info next; }

r->next = temp; temp->next = p; } } */

template void LList :: insertItem (node *&p, T item ) { if ( p == NULL || item info ) { node *temp = p; p = new node; p->info = item; p->next = temp; } else insertItem (p->next, item); }

template void LList :: insertItem ( T item ) { insertItem (first, item); }

template void LList :: deleteItem(T item) { if ( first == NULL || item info ) cout *p = first;

if ( item == first->info ) { first = first->next; delete p; } else { node *r = p; p = p->next;

while ( p != NULL && p->info next; }

if ( p == NULL || p->info > item ) coutnext = p->next; delete p; } } } }

template void LList :: destroy() { node *p;

while ( first != NULL ) { p = first; first = first->next; delete p; }

}

template void LList :: copy ( const LList & other ) { if ( other.first == NULL ) first = NULL; else { first = new node; first->info = other.first->info;

node *p = other.first->next; node *r = first;

while ( p != NULL ) { r->next = new node; r->next->info = p->info; p = p->next; r = r->next; } r->next = NULL; } }

template int LList :: getLength() { int counter = 0; node *p = first;

while ( p != NULL ) { counter++; p = p->next; } return counter; }

template bool LList :: searchItem (T item) { bool found; found = false;

node *p = first;

while ( !found && p != NULL ) { if ( p->info == item ) found = true; else p = p->next; }

return found; } /* template void LList :: printList() { if ( first == NULL ) cout *p = first;

while ( p != NULL ) { coutinfonext; }

cout void LList :: printList (node *p) { if ( p != NULL ) { coutinfonext); } }

template void LList :: printList () { if (first == NULL ) cout

}

/*template void LList :: printList() { if ( first == NULL ) cout

node *p = first;

while ( p != NULL ) { temp[index++] = p->info; p = p->next; }

for ( int i = size -1; i >= 0; i--) cout

delete [] temp; } }

*/

template void LList :: printReverseList (node *p) { if ( p != NULL ) { printReverseList (p->next); coutinfo

template void LList :: printReverseList () { if (first == NULL ) cout

}

template int LList :: occurrences ( T item ) { return occurrences (item, first); }

template int LList :: occurrences ( T item, node * p ) { int count = 0;

if ( p == NULL ) return 0; if ( p->info == item ) count++;

return count + occurrences (item, p->next); }

CIRCULAR SORTED LINKED LIST CLASS Design and implement a class representing a circular sorted linked list. The class, called CList, must have the following requirements: 1. The linked list and the nodes must be implemented as C++ templates 2. The class has only one private data member: a pointer to the last node. 3. It must include a constructor, a destructor, a copy constructor and an operator= 4. It must include functions to destroy a list, copy a list, insert a given item in the list, delete a given item from the list, search for a given item in the list, check if the list is empty, return the length of the list and print the list in ascending order

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!