Consider the following definitions for linked lists for problems 6 through 9. typedef int elementType; class LinkedList { public: LinkedList(); //other member functions . . . private: struct node { elementType data; node * next; }; node * first; }; 9. Write the method of the LinkedList class to calculate and return the range of the data values stored in an unsorted singly linked list. (Note: range = largest value – smallest value). Note: If list is empty return 0. int LinkedList::range() Solution //function to calculate range in linked list int LinkedList::range() { elementType smallest,largest,range; // point to the beginning of the list node* ptr=first; //if list empty, return 0 if(ptr==NULL) return 0; //list is not empty //assume element in the beginning of the list is smallest smallest==first->data; //start from second element in list ptr=ptr->next; //traverse the list till end while(ptr!=NULL) { //compare smallest with the items in the list if(ptr->data<smallest) { //if any element is less than smallest //replace the smallest with that element smallest=ptr->data; } //move to the next node ptr=ptr->next; } largest=first->data; ptr=first->next; while(ptr!=NULL) { if(ptr->data>largest) { largest=ptr->data; } ptr=ptr->next; } //find range and return it range=largest-smallest; return range; } .