// Recursive function void DepthFirstSearch::recursion(int node, stack & obj) { List *ptr = new List(); if(obj.isStackEmpty()){ ptr = NULL; delete ptr; cout << "The node value is not found." << endl; return; } int value = obj.getTop(); for(ptr = head; ptr != NULL; ptr = ptr->next) { if(ptr->first == value && !obj.isVisited(ptr->sec)){ obj.push(ptr->sec); value = ptr->sec; } if(value == node){ cout << "The node value is found!" << endl; cout << "The path is : "; obj.printStack(); return; } } obj.visitedNode(value); obj.pop(); recursion(node, obj); }