Question: JAVA Consider the following relation: Given an integer n > 4 the Collatz successors of n are defined to be: C(n) = {n is even
JAVA

Consider the following relation: Given an integer n > 4 the Collatz successors of n are defined to be: C(n) = {n is even AND ((n - 1) mod 3 = 0) {2 times n, (n - 1)/3} Otherwise {2 times n} Given an integer n > 4 the Collatz graph G_n(V, E) where V is the set of vertices of G_n, and E is the set of edges of G_n, is constructed by: 1. Set n to be a vertex in V 2. For each vertex j elementof V add C(n), the Collatz successor[s] of j, to V. Add the edges from j to its successors to E. It can be shown that under the assumption that the conjecture holds, and by definition of the graph, G_B(V, E) is an infinite tree that spans all the positive integers except for 1, 2, and 4. Consider the following tree construction (enumeration) algorithm: 1. Given the integer n = 8 and an empty queue, Q, insert n into Q. 2. Do forever: a. Remove the head element from Q (assume it is the integer j). b. Print j to a file c. Insert the successor[s] of j to Q. Assignment Instructions: Your assignment is to write a Java program that implements the above algorithm using a Queue Abstract Data Type. The program terminates the tree construction after 20 iteration of the given algorithm
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
