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];

For unlimited access to Homework Help, a Homework+ subscription is required.

Unlock all answers

Get 1 free homework help answer.
Already have an account? Log in
Already have an account? Log in
Already have an account? Log in
Already have an account? Log in
Already have an account? Log in
Already have an account? Log in
Already have an account? Log in
Already have an account? Log in
Already have an account? Log in
Already have an account? Log in
Already have an account? Log in
Already have an account? Log in
Jarrod Robel
Jarrod RobelLv2
16 Oct 2018
Already have an account? Log in

Related questions

Related Documents

Weekly leaderboard

Start filling in the gaps now
Log in