Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(I need help with this code. You only have to do the TODO part) Q2driver.cpp: SLL.cpp: SLL.hpp: 2. 30 points You are given a singly
(I need help with this code. You only have to do the TODO part)
Q2driver.cpp:
SLL.cpp:
SLL.hpp:
2. 30 points You are given a singly linked list class SLL (partial) implementation where each node consists of a single key value of char type. You are required to implement two member functions char at Index(int i) and bool palindrome (). 1. The function char at Index(int i) returns the character at the index i of the linked list. Note that we, the computer scientists, count from 0. Hence, the head of the list is the 0 index node, the next element is the 1 index node, and so on. Your function should terminate gracefully by printing an error message and returning the null character '\0' ifi is not a valid index (e.g. i is either negative or greater than or equal to the length of the linked list). You can safely assume that the null character '\0' is not a member of the linked list. 2. The function bool palindrome () returns true if the sequence of characters of the linked list is a palindrome Recall that a palindrome is a sequence of characters which reads the same backward as forward, such as tacocat or racecar. For the purpose of this question, we assume that empty lists are palindromes, and so are lists with only one node. Hint: The atIndex function. Example A. Let 11 be an object of the SLL class. If 11 has the following config- uration: d m null head m Then, 11.palindrome () should return true, while 11.atIndex (0) and 11.at Index(4) should both return m. On the other hand, 11.atIndex(-1) and 11.at Index(8) should return the null character ('\0') and print an error message. Similarly, if 11 has the following configuration: a a null head then 11.palindrome () should return false. Within your function, you are allowed to construct a local linked list if it helps you to solve the problem. However, you must deallocate (free) any heap memory that is no longer required. You are not allowed to use an array, a vector, or any of the string library functions. Hinclude
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started