Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use binary search tree data structure !!!! Assignment #5 Due Sunday April 23 before class Please submi on the OCS Q1, 45 pts) Using Binary

use binary search tree data structure !!!! image text in transcribed
image text in transcribed
image text in transcribed
Assignment #5 Due Sunday April 23 before class Please submi on the OCS Q1, 45 pts) Using Binary Search tree data structure, design and implement a Phone Book to store and retrieve telephone numbers. You must code the following: 1) Class Person includes four private instance variables: String name, int telephone, Person len and Person night. It contains the following public methods: A constructor that initalizes the instance variables name and telephone. Set and get method for each instance variable. 2) Class PhoneBook Tree includes one private instance variable Person Root contains the following public methods: A method insert that takes String name and integer telephone, creates and inserts a new Person node into the binary tree, based on the telephone number. A method printPreorder that traverses and prints the contents of the tree in a pre-order. The method prints the tree in a hierarchical order showing the node level number and its data, as shown in the sample output. A method identical that receives a PhoneBookTree object retums true two trees are identical and false otherwise. A methed Count that returns the count of telephone numbers that start with one. For example, a telephone number 1180180 A method Search that receives a String name and retums the corresponding number. Mthe name was not found in the tree, the method returns 1. IHint You need to declare private methods inside the class. A methods are recursive] 30 Class PhoneBookTest. In the main method, do the following: Create two objects of class PhoneBookTree: tree1 and tree2. Insert the following data in tree 1

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_2

Step: 3

blur-text-image_3

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

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions