13
answers
0
watching
187
views
16 Oct 2018
34. Which line of code would you add to the Graph.java (code 5) on line 18 to pick two random nodes from your array of nodes? These will then be connected to each other. N.B. Math.random() returns a real number (double) between 0 and 1. (A) GraphNode nodel = graph[ (int) (Math.random() *n)]; GraphNode node2 = graph[ (int) (Math.random() *n)]; (B) GraphNode nodel = graph[ (int) Math.random() *n); GraphNode node2 = graph [ (int) Math.random() *n); (C) GraphNode nodel = graph [Math.random() *n]; GraphNode node2 = graph [Math.random() *n]; (D) int pos = (int) Math.random() *n; GraphNode nodel = graph [pos]; GraphNode node2 = graph [pos]; (E) int pos = (int) (Math.random() *n); GraphNode nodel = graph [pos]; GraphNode node2 = graph [pos];
34. Which line of code would you add to the Graph.java (code 5) on line 18 to pick two random nodes from your array of nodes? These will then be connected to each other. N.B. Math.random() returns a real number (double) between 0 and 1. (A) GraphNode nodel = graph[ (int) (Math.random() *n)]; GraphNode node2 = graph[ (int) (Math.random() *n)]; (B) GraphNode nodel = graph[ (int) Math.random() *n); GraphNode node2 = graph [ (int) Math.random() *n); (C) GraphNode nodel = graph [Math.random() *n]; GraphNode node2 = graph [Math.random() *n]; (D) int pos = (int) Math.random() *n; GraphNode nodel = graph [pos]; GraphNode node2 = graph [pos]; (E) int pos = (int) (Math.random() *n); GraphNode nodel = graph [pos]; GraphNode node2 = graph [pos];
29 Jun 2023
marcusnicole284Lv10
16 Jun 2023
Already have an account? Log in
14 Jan 2023
Already have an account? Log in
papayaprofessorLv10
5 Sep 2022
Already have an account? Log in
learn4lifeLv10
14 Jul 2022
Already have an account? Log in
teacherrecoLv10
14 Jul 2022
Already have an account? Log in
Jarrod RobelLv2
16 Oct 2018
Already have an account? Log in