Chat with us, powered by LiveChat computer science only | Writedemy

computer science only

computer science only

Liem Le | COSC2436 #1

School of Engineering and Technology

COSC2436 – LAB 7

Title Tree Data Structure – Binary Search Tree

Time to

complete Two weeks

COURSE OBJECTIVES

LEARNING OUTCOME LAB OBJECTIVES

-Apply Object Oriented programming

-Complete the lab on time (Time

Management)

-Do the lab by following the project process:

analysis, design, write the code, test, debug,

implement

-UML of data type class

-Write comments

-Write the code of data type classes including

data members, no-argument constructor,

parameter constructors, mutator methods,

assessor methods, toString and other methods

-INHERITANCE: write the code of child classes

including, data members, constructors and

other methods inherited from parent class

-apply Polymorphism: using object of the

parent class to point to object of child classes

-control structure: if..else, switch, do..while

-create object, access members of data type

class

-format the output in columns and double

numbers with 2 decimal digits

-display message box

-create and access 4 operations of the tree

data structure

-Create a new project, add source file to the project,

compile and run the program without errors and qualified

to the requirement

-Declare variables of int, double, String;

-provide UML of data types

-Create data types with data members, constructors,

mutator methods

-Apply Inheritance relationship

-Apply polymorphism in the project

-provide the pseudo-code of program

-create and manage the menu to loop back to re-display

after each task: using do.. while

-Use switch statement to determine and define the action

for each task

-Format the output in columns and double numbers wiwth 2

decimal digits

-Display message box

-can figure out the base case, reduce problem, general

solution and recursion algorithm to write the recursion code

for some problems, such as,

* factorial (int n), sum(int n), sum (int m, int n), fibonacci(int

n), and some other cases in real life, etc.

-can create the tree and access operations of the tree:

insert, fetch, delete, update and showAll

Liem Le | COSC2436 #2

Skills

required to

do the Lab

To do this lab, students have to know:

-Review to create the pseudo-code or a flowchart of a lab

-Review the syntax to create a data type class with data members, constructors, mutator

accessor methods, method toString

-Review how to define a child class including data member, constructor, toString and other

methods inheriting from parent class:

-Review how to declare an object in main(), how to access the methods of data type classes

from main()

-Review how to apply polymorphism

-Review control structure: if..else, switch, do..while loop

-How to set the decimal digits (2) of a double number

-How to display the message box

-How to recognize base case, reduce problem, general solution an recursion algorithm to help

writing the recursion code

-Understand the code of class BinarySearchTree and know how to access its operatons

LAB

INSTRUCTION

REQUIREMENT PART 1

Write an application that allows users to work with the recursion algorithm to calculate

values of the following. The recursion algorithm of each one will be defined in a static

function of a separated data type class

n! Factorial of an integer n where n provided from the keyboard

an a power n, where a and n are int numbers provided from the keyboard

Sum (n) Sum(n) = 1 + 2 + 3 + .. + n where n is an int provided from the keyboard

Sum (m,

n)

Sum(m, n) = m + (m+1), (m+2) + … + n where m and n are int numbers

provided from the keyboard

Fn Fibonacci sequence Fn = Fn – 1 + Fn-2; F0 = 0 and Fn1 = 1

GCD

(n,m)

The greatest common divisor (GCD) of two integers m and n; m > n

where m, n are provided from the keyboard

In the application will allow users to select the task to do. After finishing one task, users can

select to work with another task until they want to exit

1. n! (Factorial of an integer n) 2. an (a power n) 3. Sum(n) = 1 + 2 + 3 + .. + n 4. Sum(m, n) = m + (m+1), (m+2) + … + n 5. Fibonacci sequence Fn 6. GCD (The greatest common divisor of m and n)

The m and n are integer number that are read from the keyboard

The output should be, for example:

Factorial of n = 5 is 120

2 to the power 3 is 8

Liem Le | COSC2436 #3

Sum from 1 to 10 is: 55

Sum from 5 to 7 is 18

The Fibonacci at 10 is 55

Greatest Common Divisor (GCD) of 120 and 90 is 30

HOW TO DO

PART 1

Step: Write the code

-start editor create the project, add RecursionStaticMethods_yourLastName file and

write Recursion static methods

-Add the driver class DemoRecursion_yourLastName and follow the pseudo-code and use

java to write the code of the program

*Step3: compile and run the program

*Step4: debug if there is any errors to complete the program

LAB7

PART2

REQUIREMENT PART 2:

Create an application that allows users can work on the information of BankCustomer with

the following tasks:

1. Insert 2. Fetch 3. Uncapsulation 4. Update 5. Delete 6. Show all

INSERT

-Allow users to enter the information of a BankCustomer from the keyboard

-Create the object then insert to the data structure

FETCH

-Allow users to type a customer id then search in the data structure to look for the

BankCustomer. If it is found, print out the information on the screen otherwise display the

message: “The customer cannot be found”

ENCAPSULATION

-Allow users to type a customer id from the keyboard. Search in the date structure. If the

customer is found, ask for new address from the keyboard and change the address of the

customer

-Fetch the customer with the same provided id to a different object. Then compare the their

address.

If both the addresses are the same then display the message “Binary Search Tree structure is

not encapsulated”

otherwise display the message “Binary Search Tree structure is encapsulated” =[

UPDATE

Display the message to ask users to enter the customer id. Using the customer id to read the

node out from the data structure as a customer.

Liem Le | COSC2436 #4

Asking for the new phone number from the keyboard and change the phone of the customer

Update the data structure with the new node with new phone with the same customer id.

Display the message “Update successful” or Updte failed”

DELETE

Display the message to ask users to enter the customer id. Remove the node with the

entered id

Display the message to see if delete successfully or not

SHOW ALL

Display all the BankCustomers are currently stored in the data structure

HOW TO DO

PART 2

Step1: Write the pseudo-code

Step2: Write the code

-start editor create the project, add BankCustomer_yourLastName that you had in lab 6

and add class BinarySearchTree (use the code on the page 394- 396 for your reference ON

THE PAGE 396 LINE 110 return true CHANGE TO return false)

–Also, the current code on page 396 does not take care deleting the rood, you should

add the code to delete the root in 3 cases: root has no child, has one child and has two

children

-Add the driver class Demo_TreeDataStructure_yourLastName and follow the pseudo-

code and use java to write the code of the program

*Step3: compile and run the program

*Step4: debug if there is any errors to complete the program

HOW TO

TURN IN

RecursionStaticMethods_yourLastName.java

Demo_Recursion_yourLastName.java

RecursionStaticMethods_yourLastName.class

Demo_Recursion_yourLastName.class

Pseudo-code of part 1

BankCustomer_yourLastName.java

BinarySearchTree.java

Demo_TreeDataStructure_yourLastName.java

BankCustomer_yourLastName

BinarySearchTree.java

Demo_TreeDataStructure_yourLastName

Pseudo-code of part 2

IF YOU GET ANY PROBLEM TO SUBMIT FILE .class, YOU CAN SUBMIT ALL PROJECT INTO ONE

FILE .zip or .rar TO SEND

Liem Le | COSC2436 #5

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order