Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java program using eclipse. I have to make the three test cases as showed on the bottom of second image. TreeNode.java: public class TreeNode {

java program using eclipse. I have to make the three test cases as showed on the bottom of second image. image text in transcribedTreeNode.java:

public class TreeNode { private T element; // data field private TreeNode left; // reference to left child node private TreeNode right; // reference to right child node public TreeNode() // POST: empty tree node { element = null; left = right = null; } public TreeNode (T elem) // POST: tree node with element set { element = elem; left = right = null; }

public TreeNode (T elem, TreeNode left, TreeNode right) // POST: tree node with element and child nodes { element = elem; this.left = left; this.right = right; } // accessors and mutators public T getElement() { return element; } public void setElement(T element) { this.element = element; } public TreeNode getLeft() { return left; } public void setLeft(TreeNode left) { this.left = left; } public TreeNode getRight() { return right; } public void setRight(TreeNode right) { this.right = right; } public boolean isLeaf () // POST: return true if node is a leaf node { return (left == null && right == null); } }

morsecode.txt:

e o t - i o o a o - n - o m - - s o o o u o o - r o - o w o - - d - o o k - o - g - - o o - - - h o o o o v o o o - f o o - o l o - o o p o - - o j o - - - b - o o o x - o o - c - o - o y - o - - z - - o o q - - o -

image text in transcribed

Part II (70 pts.) The Morse code is used to encode messages where each letter is coded as a unique series of dashes and dots. This problem will practice building a binary tree to store the alphabet letters. Code will use the TreeNode.java class built in lecture. The text file below lists each letter followed by its code. Files are on First Class. morsecode Notepad File Edit Format View Help e O 1 O O a O s o o o u O O r O W O O O h o o o o V O O O f o o 1 o O O p o O OO O O O O O Store each letter of the alphabet in a binary tree. The root node stores no letter. Travel to the left represents a dot and travel to the right represents a dash. Build the tree using the Morse code to travel left or right and then insert the letter. a. Initially the tree has a root node with no element. b. Read the first line of the text file: e o Letter e is represented by a single dot. Travel begins from the root. Dot means travel left. There is no left child encountered so make a node and insert letter e

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

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago