Question: Does this code do everything the question asks ? JAVA public int value(Node node) { int value=node.data; //Saves data in node of node, passed in

 Does this code do everything the question asks ? JAVA public

Does this code do everything the question asks ? JAVA

public int value(Node node) { int value=node.data; //Saves data in node of node, passed in the function int diffNode=0; //to count no. of data different from the value int linkscount=0; //to count total number of links while(node!=null) { if(node.data!=value) //There would be a minor change here. SInce this function doesn't have "target" node, and hence, "target.data" will give error. //So, we replace it with "value=node.data". When node changes after every loop, the data in "value" is same, used to compare data of every node. { diffNode++; } linkscount++; //THis increment operation would be outside the "if" condition node=node.prev; // going back to previous node } return diffNode+linkscount; //returning the sum of diffNode and linkscount }

b. A value method value PLUS the number Node letters different number of and returns the of (node) takes a links back to start

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!