Write a recursive function to print portion of a linked list
Solution
Hi, I wrote function in C++.
// function to print linked list in reverse order from node P to node Q
// lets assume that structure of Node is:
 struct Node{
   Node *next;
    int data;
 };
void printRecursive(Ndoe *p, Node *q){
   // if list is empty
    if(p == NULL)
        return;
   
    // base case, if we have only one node
    if(p == q){
        cout<<q->data<<endl;
        return;
    }
   // call recursively for next node
    printRecursive(p->next);
   // print p\'s data
    cout<<p->data<<endl;
}

