Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Jeliot, execute the following tree algorithm: import Prog1Tools.IOTools; class Node { Node left; Node right; int value; public Node(int value) { this.value = value;

Using Jeliot, execute the following tree algorithm: import Prog1Tools.IOTools; class Node { Node left; Node right; int value; public Node(int value) { this.value = value; } } public class GeneralTreeTest { public static void main(String[] args) { // build a simple tree add 5 nodes to the tree Node root = new Node(5); System.out.println("Tree Example"); System.out.println("Building tree with root value " + root.value); insert(root, 1); insert(root, 8); insert(root, 6); insert(root, 3); insert(root, 9); System.out.println("Traversing tree "); printOrder(root); } public static void insert(Node node, int value) { if (value < node.value) { if (node.left != null) { insert(node.left, value); } else { System.out.println(" Inserted " + value + " to left of " + node.value); node.left = new Node(value); } } else if (value > node.value) { if (node.right != null) { insert(node.right, value); } else { System.out.println(" Inserted " + value + " to right of " + node.value); node.right = new Node(value); } } } public static void printOrder(Node node) { if (node != null) { printOrder(node.left); System.out.println(" Traversed " + node.value); printOrder(node.right); } } }

This algorithm first inserts five nodes into a tree structure and then traverses the tree. Using the Jeliot environment, load, compile and execute this java algorithm to understand its operation. Determine the kind of tree structure that is being created and determine what kind of traversal the algorithm is conducting.

Finally, conduct an Asymptotic analysis for the provided algorithm and report your analysis including Big O, Big Omega, or Big Theta as appropriate.

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

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

How can a currency crisis lead to higher interest rates?

Answered: 1 week ago

Question

Question Can a Keogh plan fund be reached by the owners creditors?

Answered: 1 week ago

Question

Question What happens to my plan if I die?

Answered: 1 week ago