Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Given an integer n the Collatz successors of n are defined to be: B(n) = {n is even n/2 Otherwise n * 3 +

JAVA image text in transcribed
Given an integer n the Collatz successors of n are defined to be: B(n) = {n is even n/2 Otherwise n * 3 + 1 The trajectory of n, is defined to be the list of successors of n (n is the starting point or SP). Reaching 1 as a successoris considered "success." The Collatz Tree (forward chaining). Consider the following relation: Given an integer n > 4 the Collatz successors of n are defined to be: F(n) = {n is even AND ((n - 1) mod 3 = 0) {2 times n, (n - 1)/3} Otherwise {2 times n} Consider the following forward chaining procedure: Given the integer n (goal) and a collection of integers that initially includes only the integer 8. Following a collection management policy (e.g., FIFO), Do: a. Remove an integer (say j) from the collection b. Insert the successor[s] of j to the collection. c. Stop with "success" if n is in the collection Assignment Instructions: Your assignment is to write an interactive Java program that: Obtains the desired chaining mode via a widget (from the user) Obtains the number n via a widget Obtains a limit (l) on the number of iterations of successors generation via a widget Implements the appropriate chaining method: using a sorted list and removing the least element from the list for the forward chaining a. Implement the Comparable and/or Comparator interface(s) in order to sort the list (do NOT write your own sort function, do not use Maps!) At each iteration the backward chaining module prints the trajectory followed so far into a new line in a csv file and the forward chaining module prints the current contents of the collection to a csv file. The program terminates after l iterations of successor generation and reports the status (success or failure) of the run under the l- constraint - via a widget

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago