Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In JAVA please, please follow all instructions exactly 8. (8 points) Given the following class IntNode, complete method static boolean doubled(int i, IntNode 1s) to
In JAVA please, please follow all instructions exactly
8. (8 points) Given the following class IntNode, complete method static boolean doubled(int i, IntNode 1s) to return true if the in teger, i, appears in at least two consecutive nodes in the list and false otherwise. You may assume the list is NOT headed. Examples: Is > 10->20 doubled (10, 1s); >30 > 10 --> 20 --> 51 returns false because 10 is not found in any two consecutive nodes Is >10 > 20 > 20 > 10 -> 51 doubled (20, 1s); returns true because 20 appears consecutively Is 10->20 --> 20 > 20 -> 51 doubled (20, 1s); returns true because 20 appears consecutively (and actually more) public class IntNode { private int value; private IntNode next; public IntNode(int v, IntNode node) { value = v; next = node; } public IntNode() {} public int getValue() { return value; } public void setValue(int v) { value = v; } public IntNode getNext() { return next; } public void setNext (IntNode node) { next = node; } public static boolean doubled(int i, IntNode 1s) { // complete this method } // class IntNode
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres the completed doubled method that checks if an integer appears in at least two consecutive nod...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started