CSC211 - T2_Prac1_StdNum.java - IT Assignment Help

Download Solution Order New Solution
Assignment Task

 

Create a Java file and name it T2_Prac1_StdNum.java to complete questions 1, 2, and 3.
Create a Word processing file and name it T2_Prac1_StdNum_Surname_Initials.doc to complete question 4.

1. Write a recursive buildBinaryTree method that builds a new binary tree from the contents of an array that contains integers. Use the following class definition for a node in a binary tree: class BinaryNode { int element; BinaryNode left; BinaryNode right;}

Hint: Take one item from the array and insert it as the root of the tree. Divide the remaining items in half and insert one half in the right subtree and the other half in the
left subtree of the root node by calling the method recursively with the relevant array indices.

Note: You have to explain your method by means of inline comments or by including a pseudo-code version of this method in comments.

2. Write a method oddEntries that returns the number of odd integers contained in a binary tree where the element type is int. This method is called with a link to the root node of the tree.

Note: You have to explain your method by means of inline comments or by including a pseudo-code version of this method in comments. 

3. Write a Java program that:
a. Reads the integers in the text file (Input.txt) into an array.
b. Constructs a binary tree using the buildBinaryTree method from the input of the array. (Use the given BinaryNode class but do not use the merge method to build a tree.)
c. Use the given printInOrder and printPreOrder (in the given BinaryNode class) method to print the contents of the tree.
d. Uses the oddEntries method from question 2 to return the number of odd integers contained in the tree.

4. Consider the result from the Java program above to answer the following questions:
Write your solutions in the new Word document you created.
e. Which item/node is contained in the root of the tree? Give a reason.
f. Which items/nodes are contained in the left subtree of the root node? Give a reason.
g. Which items are contained in the right subtree of the root node? Give a reason.
h. What is the number of odd entries in the tree?
i. Draw the tree.

5. Zip both the files T2_Prac1_StdNum.java and T2_Prac1_StdNum_Surname_Initials.doc, and rename the zipped file as T2P1_StdNum_Surname_Initials.zip.

 

This CSC211 - IT Assignment has been solved by our IT experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.