Question: Language: C++ Write a function find(Node* node, int valueInput) that starts at the given node and returns the index of the node with the value

Language: C++

Write a function find(Node* node, int valueInput) that starts at the given node and returns the index of the node with the value valueInput. Indices start at 0. Return -1 if valueInput does not exist.

We have defined the following node C++ class for you:

class Node { public: int value; Node* next = NULL; };

Sample Input 1:

5 1->2->5

Sample Output 1:

2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!