File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,13 @@ int OneWayLinkedList::hasNode(int data) {
8787 return 0 ;
8888}
8989
90+ // Check there is a node with a specific data in the list or not (with a recursive function)
91+ int OneWayLinkedList::hasNodeRecursive (int data, Node* node) {
92+ if (node == NULL ) return 0 ;
93+ if (node->data == data) return 1 ;
94+ return hasNodeRecursive (data, node->next );
95+ }
96+
9097// Get the first node
9198Node* OneWayLinkedList::getFirstNode () {
9299 return this ->head ;
Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ class OneWayLinkedList {
5050 // Check there is a node with a specific data in the list or not
5151 int hasNode (int data);
5252
53+ // Check there is a node with a specific data in the list or not (with a recursive function)
54+ int hasNodeRecursive (int data, Node* node);
55+
5356 // Delete a node with a specific data
5457 void deleteNode (int data);
5558
You can’t perform that action at this time.
0 commit comments