Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hey there, me again. An assignment this time rather than a lab. Any help would b

ID: 666554 • Letter: H

Question

Hey there, me again. An assignment this time rather than a lab. Any help would be appreciated. This one is due at 5:45EST today. :-/

Thanks!

Files required are below in the dropbox link.

https://www.dropbox.com/s/qh3d7dbc1hcd0s7/lab05-singly_linked_list.zip?dl=0

le List ADT 65 Programming Exercise 1 List data items need not be one of C++'s built-in types. The following declaration, for example, represents a slide show presentation as a list of slides List slideShow; where each slide is an object in the Slide class outlined here. class Slide public: static const int HEIGHT = 10, void display() const; char image [HEIGHT] [WIDTH]: // Slide dimensions WIDTH = 36 ; // Display slide and pause private: /I Slide image // Seconds to pause after // displaying slide int pause; friend istream& operator>> (istream& in, Slide& slide): friend ostream& operator

Explanation / Answer

Linkedlist.cpp #include "ListLinked.h" template List::List(int ignored) { head = NULL; cursor = NULL; } template List::List(const List& other) { ListNode* copy = other.head; while (copy != NULL) { this->dataItem = copy->dataItem; this->next = copy->next; gotoNext(); copy = copy->next; } *this = other; } template List& List::operator=(const List& other) { ListNode* copy = other.head; while (copy != NULL) { insert(copy->dataItem); gotoNext(); copy = copy->next; } return *this; } template List::~List() { ListNode* trash; ListNode* step = head; while (step != NULL) { trash = step; step = step->next; delete trash; } head = NULL; } template //fixed problem with adding between nodes void List::insert(const DataType& newDataItem) throw (logic_error) { if (!isEmpty()) { ListNode* tempNode = cursor; cursor = new ListNode(newDataItem, tempNode->next); tempNode->next = cursor; } else if (isEmpty()) { head = new ListNode(newDataItem, 0); cursor = head; } } //Needs work. Only works if attempting to remove from empty list or if removing head item. //Problems if remove from list past head position. template void List::remove() throw (logic_error) { ListNode* lostNode; if (isEmpty()) { cout next; } if(cursor->next != NULL) cursor = cursor->next; else cursor = head; previous->next = lostNode->next; delete lostNode; lostNode = NULL; } } template void List::replace(const DataType& newDataItem) throw (logic_error) { if(head != NULL) cursor->dataItem = newDataItem; } //Dangling memory? template void List::clear() { if (isEmpty()) { cout next != NULL){ cursor = cursor->next; } } template bool List::gotoNext() throw (logic_error) { if (cursor->next != NULL) { cursor = cursor->next; return true; } else { return false; } } template bool List::gotoPrior() throw (logic_error) { if(cursor != head && head != NULL){ ListNode *findPrior = head; while(findPrior->next != cursor) findPrior = findPrior->next; cursor = findPrior; return true; } else return false; } template DataType List::getCursor() const throw (logic_error) { if (!isEmpty()) { return cursor->dataItem; } else{ ListNode* logic_error; throw logic_error; } } // Programming exercise 2 template void List::moveToBeginning () throw (logic_error) { if (cursor != head && head != NULL) { ListNode* findPrior = head; while(findPrior->next != cursor) { findPrior = findPrior->next; } findPrior->next = cursor->next; cursor->next = head; head = cursor; } } // Programming exercise 3 template void List::insertBefore(const DataType& newDataItem) throw (logic_error) { if (isEmpty()) { head = new ListNode(newDataItem, 0); cursor = head; } else { if (cursor == head) { ListNode *node = new ListNode(newDataItem, head); head = node; cursor = node; } else { gotoPrior(); insert(newDataItem); } } } template void List::showStructure() const { // Outputs the items in a list. If the list is empty, outputs // "Empty list". This operation is intended for testing and // debugging purposes only. if ( isEmpty() ) { cout