Question: 1st code: import java.util.ArrayList; import java.util.List; public class Node { public int value; public List children; public Node(int value) { this.value = value; this.children =
1st code:
import java.util.ArrayList;
import java.util.List;
public class Node {
public int value;
public List
public Node(int value) {
this.value = value;
this.children = new ArrayList
}
public List
List
if (root == null) {
return path;
}
if (root.value == valueToSearch) {
path.add(root);
return path;
}
for (Node child : root.children) {
List
if (!childPath.isEmpty()) {
path.add(root);
path.addAll(childPath);
return path;
}
}
return path;
}
}
2nd code:
import java.util.List;
import java.util.ArrayList;
public class Triangle {
public static List
int max_perimeter = 0;
List
for (int i = 0; i < lines.size(); i++) {
for (int j = i + 1; j < lines.size(); j++) {
for (int k = j + 1; k < lines.size(); k++) {
int a = lines.get(i), b = lines.get(j), c = lines.get(k);
if (a + b > c && a + c > b && b + c > a) {
int perimeter = a + b + c;
if (perimeter > max_perimeter) {
max_perimeter = perimeter;
max_triangle = List.of(a, b, c);
}
}
}
}
}
return max_triangle;
}
}
can you please make this codes executable in an online compiler without errors because I posted a question here specifically stating " please include an Online link to see and to run the codes on an online compiler site which has no access problems."
even if there was no link, I wanted the code runnable at least, but it gave me this error: "class Triangle is public, should be declared in a file named Triangle.java" and a similar one for the first code but even thought I tried searching "how to execute it in an online complier" and tried writing the call function it still wasn't running and even giving me more errors sometimes, I couldn't figure it out for both codes so please help and thank you in advance
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
