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

You have implemented LinkList Class for your Prog#4 which should have insert and

ID: 3764733 • Letter: Y

Question

You have implemented LinkList Class for your Prog#4 which should have insert and remove methods implemented Now you need to implement one more method: checkPalindrome() which is to check if the LinkList is a palindrome or not Return true if the linklist is palindrome, otherwise, return false

Explanation / Answer

#include using namespace std; // General list node class Node { public: Node() { mData = -1; mNext = NULL; } ~Node() {} int data() { return mData; } void setData(int data) { mData = data; } Node* next() { return mNext; } void setNext(Node* next) { mNext = next; } private: int mData; Node* mNext; }; // General list class class List { public: List() { mHead = NULL; mCount = 0; } ~List() {} Node* head() { return mHead; } void setHead(Node* head) { mHead = head; } void append(int data) { Node* tmp = new Node(); tmp->setData(data); if ( mHead == NULL ) mHead = tmp; else { Node* ptr = mHead; while ( ptr->next() != NULL ) { ptr = ptr->next(); } ptr->setNext(tmp); } } void prepend(int data) { Node* tmp = new Node(); tmp->setData(data); tmp->setNext(mHead); mHead = tmp; } void print() { Node* ptr = mHead; while ( ptr != NULL ) { cout data() ); n1 = n1->next(); return flag; } private: Node* mHead; int mCount; }; int main() { List* l = new List(); l->append(100); l->append(200); l->append(300); l->append(400); l->append(300); l->append(200); l->append(100); l->print(); Node* n1 = l->head(); bool stat = l->isPalindrome(n1, n1); if ( stat ) { cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote