Question
Below is the content of linkedlist.h that contains the declaration of functions that you will implement in subsequent questions. //filename: linkedlist.h #ifndef LINKEDLIST_H #define LINKEDLIST_H
Below is the content of linkedlist.h that contains the declaration of functions that you will implement in subsequent questions. //filename: linkedlist.h #ifndef LINKEDLIST_H
#define LINKEDLIST_H #include node.h //IMPORTANT: In all the functions the linked-list may only contain //letters of the alphabet in either lower or upper case
//Precondition: The address of a valid LinkedList and a char value //that may be an alphabet in either lower or upper case //Postcondition: Adds a new node with data element set to value to the //end of the linked list.
void addToEndOfList(LinkedList*& list, char value);
//Precondition: A char array with a given length, not necessarily a //C-string but containing only letters of the alphabet //Postcondition: The address of a new LinkedList containing all the //characters of the input array in the same order, where each node of //the linked list contains one character of the array.
LinkedList* arrayToLinkedList(char* arr, int len);
//Precondition: The address of a valid LinkedList and a char value //that is an alphabet in either lower or upper case //Postcondition: Returns the number of occurrences of the given //alphabet in either lower or upper case in the linked list
//You must use an iterative implementation (loops). int countCharIterative(LinkedList* list, char value);
//Precondition: The address of the first node in a linked list and a //char value that is a letter of the alphabet in either lower or upper //case. //Postcondition: Returns the number of occurrences of the given char // value in the linked list using a recursive implementation.
int countCharHelper(Node* head, char value);
//Precondition: The address of a valid LinkedList and a char value //that is a letter of the alphabet //Postcondition: Returns the number of occurrences of the given //value in the linked list in either upper or lower case. This //function uses the helper function countCharHelper()
int countChar(LinkedList* list, char value); #endif
In the following questions you may use the standard library function char tolower(char c); that takes a single character as input and returns the lower-case version of the character.
Implement the function countCharIterative()described on page 5(the information given above). As an example if mylist is the pointer to a LinkedList, then the following calls to countCharIterative()must return the given values.
countCharIterative(mylist, k) should return the value 0
countCharIterative(mylist, J) should return the value 1
countCharIterative(mylist, j) should return the value 1
countCharIterative(mylist, l) should return the value 2
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