Help me with my Java assignment using DiGraphADT, DiGraphEdge, Edges and Topological Files
Question - Ta s k 1 a simple interface DiGraphADT.java ï¬le DiGraphEdgeList.java which provides an edge list implementation of the interface an incomplete program Topological.java which reads in a text ï¬le, builds a graph from it and displays a topological ordering of nodes. a text ï¬le Edges.txt containing some data for a graph for use in the topological ordering program provided for part 3.Part 1: adjacency matrix representation. There should be a single constructor which takes the number of nodes as argument. Part 2: adjacency list representation. There should be a single constructor which takes the number of nodes as argument. Part 3: utilising a queue, as described on slide 3 of the lecture 22 handout. (Note: Queue is
...Read More
an interface in the Java Collections Framework and so although Queue should be used for the static type, a concrete type such as LinkedList should be used for the dynamic type.) Part 4:Topological, but then determines whether the digraph is acyclic or not. You may adapt the topological ordering algorithm to determine this: if the queue becomes empty but not all nodes have been ‘visited’ then the graph contains a cycle. Notes:
In this exercise, exception handling has not been included for invalid node numbers. You may assume that the node numbers passed to various methods in the graph are valid, i.e. in this exercise you don’t need to include checks for this nor handle if out of range. Parts 1, 2 and 3 and 4 are independent of each other, so for example part 3 can be attempted without having completed earlier parts. It is recommended that you tackle part 3 prior to tackling part 4. Ta s k 2 - " F i s h " Introduction The very simple game which may be known as "Fish" (or sometimes as "Animal", and which is similar in nature to 20 Questions) requires one person to think of an animal and the other person to try to guess that animal by asking in order a series of standard questions (with yes or no answers) until at the end of the series of questions a guess can be made. The person answering the questions is required to reply honestly! When a false guess is made, the questioner asks for an appropriate question and the answer to differentiate between the creature they have guessed and the one thought of, so that next time round the series of standard questions is extended. Thus the game between Tina and Jack might run: Game 1Game 2
Your task is to develop software which will let the computer adopt the role of the questioner/guesser - in the previous examples, Tina's role. What you have to do, after initialisation to handle the starting question and answer, is to build from the root up a binary decision tree. As an example the relevant part of the tree corresponding to the first game above would look as follows (in bad ascii art) - the parts indicated by "..." will either have further subtrees below them or the names of animals: Is it large? / Y/ \N / … Is it cuddly? / Tina Think of an animal. Jack Okay. Tina Is it large? Jack No. Tina Is it cuddly? Jack Yes. Tina Is it kept as a pet? Jack Yes. Tina Cat! Jack Yes. Tina I win! Another game? Tina Think of an animal. Jack Okay. Tina Is it large? Jack No. Tina Is it cuddly? Jack Ye s . Tina Is it kept as a pet? Jack Ye s. Tina Cat! Jack No. Tina I give up: what are you thinking of? Jack Dog. Tina Give me a question to differentiate between your animal and cat. Jack Does it bark? Tina And the answer for dog? Jack Ye s . Tina You won! Another game?
Y/ \N / Is it kept as a pet? / Y/ \N / Cat ... new question with two child nodes, one for each of the two "new" solutions. Thus after the second game the tree would have grown to look like this: Is it large? / Y/ \N / ... Is it cuddly? / Y/ \N / Is it kept as a pet? ... / Y/ \N / Does it bark? … / Y/ \N / Dog Cat answers) in some format that will allow the tree to be built from scratch at the start of each session and have questions added. The question-adding portion will need to check that each question has answers before adding to the tree. user, a set of valid yes/no inputs (and new questions and answers). themselves are questions or guesses at the answer.
a) Build a binary decision tree to store questions and answers. This should be put in place at the start of each session. (The size of the tree should be such that each game should consist of at least 3 questions.) 4 marks the decision tree for use in further games during the same session. c) Read data for initial tree from file (rather than hard-coding). 
 ...Read Less
Solution Preview - ion;
import java.util.Scanner;
import java.util.Stack;
public class TopologicalSort
{
private Stack<Integer> stack;
public TopologicalSort()
{
stack = new Stack<Integer>();
}
public int [] topological(int adjacency_matrix[][], int source) throws NullPointerException
{
int num