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

please help! all in c++ thank you so much! Part 3: Linked Lists, Recursion, C-st

ID: 3735537 • Letter: P

Question

please help! all in c++ thank you so much!

Part 3: Linked Lists, Recursion, C-strings You are given the files: node.h and linkedlist.h. Below is the content of node.h that contains the declarations for Node and LinkedList. These declarations are similar to those used in the construction of a linked-list in lab06 and lab07, except every node now stores a character instead of an integer. Use these declarations in the questions that follow: are construction of a linked-list in lab //filename: node.h #ifndef NODE H #define NODE H struct Node char data; Node *next; li struct LinkedList Node *head; Node *tail; l; #endif

Explanation / Answer

void addToEndOfList(LinkedList*& list, char value){

    node *p = new node;
    p->data = value;
    p->next = NULL;

   if (list->head == NULL){
       list->head = q;
       list->tail = list->head;
       return;
   }
   else {
      list->tail->next = q;
      list->tail = q;
     
   }
}

LinkedList *arrayToLinkedList(char *arr, int len){
       LinkeList *p = new LinkedList();
       for (int i = 0; i<len; i++){
           addToEndOfList(p, arr[i])
       }
       return p;
}

int countCharIterative(LinkedList *list, char value){
   count = 0;
   node *p = list->start;
   while (p!=NULL){
       if (tolower(p->data) == value || toupper(p->data) == value){
          count++;
       }
   }
   return count;
}


int countCharHelper(Node* head, char value){
   if (head == NULL)
      return 0
   else{
       if (tolower(head->data) == value || toupper(head->data) == value)
          return 1 + countCharHelper(head->next);
       else
          return countCharHelper(head->next);
   }
     
}

int countChar(LinkedList* list, char value){

return countChar(list->head, value);
}