For the SinglyLinked List class at httpsgithubcomapanangadan

For the Singly-Linked List class at: https://github.com/apanangadan/CSUF-CPSC 131/blob/master/SLinkedList.h Add a recursive function/method called printEveryOther that prints every other element starting from the first (do basically the same operation from last homework but using recursion). Show only this new function and any helper functions.

Solution

Assuming that structure in SLinkedList.h

may like this

struct node

{

   int d;

struct node *next;

}*head;

//this code may not work.. with your code, but it may help you(logic) to write code..as per your code

//printEveryOther element recursively

void printEveryOther(node *temp)

{

   if (temp==NULL)

     return ;

   if(temp!=head)

{

       cout<<temp->d<<endl;

}

return printEveryOther(temp->next);

}

 For the Singly-Linked List class at: https://github.com/apanangadan/CSUF-CPSC 131/blob/master/SLinkedList.h Add a recursive function/method called printEveryOt

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site