Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an implementation of a binary tree data structure in Java. A node should have an integer key. The implementation should include methods for inserting

Write an implementation of a binary tree data structure in Java. A node should have an integer key. The implementation should include methods for inserting a node and a tree walk method. A tree walk method is supposed to output a list of keys sorted in increasing order. Test your program in the main method of one of your classes using the following tests (tests assume the implementation contains classes BinTree with methods insertNode and treeWalk and a class Node):

// testcase 2

System.out.println();

System.out.println("testcase 1:");

BinTree binTree2 = new BinTree();

binTree2.insertNode(new Node(3));

binTree2.insertNode(new Node(201));

binTree2.insertNode(new Node(60));

binTree2.insertNode(new Node(30));

binTree2.insertNode(new Node(45));

binTree2.treeWalk();

// testcase 3

System.out.println();

System.out.println("testcase 2_1:");

BinTree binTree3 = new BinTree();

binTree3.insertNode(new Node(-10));

binTree3.insertNode(new Node(-150));

binTree3.insertNode(new Node(4));

binTree3.insertNode(new Node(300));

binTree3.insertNode(new Node(45));

binTree3.treeWalk();

binTree3.insertNode(new Node(-50));

binTree3.insertNode(new Node(200));

System.out.println();

System.out.println("testcase 2_2:");

binTree3.treeWalk();

Classes should be in package binTree.

The archive file should contain:

UML class diagram for the program generated by the SDE plug-in

Commented source code (comments per each class and method)

API docs produced by javadoc

2. Write a program in Java that will output all prime numbers up to a given upper bound (integer N which is a program input) in a computationally efficient manner using Eulers sieve algorithm (section in http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes ).

The program should take an input value N and a filename as a command line parameter and write the output to the file with that name (either creating a new file or overwriting the old one if it exists).

Comments should be provided for the implementation of the method that implements the sieve. Comments should be in javadoc format so that to produce a simple API documentation automatically

Classes should be in package primeNumbers.

The archive file should contain:

UML class diagram for the program generated by the SDE plug-in

Source code

API docs produced by javadoc

An output file with programs results

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

8.3 Describe special considerations for onboarding.

Answered: 1 week ago

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago

Question

What are the challenges associated with tunneling in urban areas?

Answered: 1 week ago