Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Description: The problem to be solved is the building of tree in RAM and then provide the capability to search the tree and retrieve

image text in transcribedProblem Description:

The problem to be solved is the building of tree in RAM and then provide the capability to search the tree and retrieve values. The data to be converted into tree form is a text file containing hierarchically-structured information. Here is an example, formatted to show the hierarchy:

Empire Burlesque

Bob Dylan

USA

Columbia

10.90

1985

Hide your heart

Bonnie Tyler

UK

CBS Records

9.90

1988

Greatest Hits

Dolly Parton

USA

RCA

9.90

1982

The CATALOG contains multiple CDs and each CD contains 6 values, TITLE, ARTIST, COUNTRY, COMPANY, PRICE and YEAR. Each entity (CATALOG, CD, TITLE etc.) is formed by enclosing a value or other entity between two tags, each formed by placing the angle-brackets () around the name of the entity. The leading tag contains the name and the ending tag contains the name, preceded by a forward-slash ( / ). Thus the TITLE entity is a text string that looks like this:

Hide your heart

The resulting tree will contain nodes containing the entities. A tree containing the information in the sample above could resemble the following diagram:

The directed lines connecting the diagram elements represent reference-variable values or pointers. The lowest-level nodes (TITLE, ARTIST etc.) will contain class-level String variables containing the values (Empire Burlesque, and Bob Dylan etc.) The rest of the tree exists merely to record the structure of the data.

There are two files associated with this exercise, one contains a more extensive catalog of CDs and the other contains a list of domestic garden plants. You can demonstrate your program on either of these files.

Your program should have a class, containing the main method and a separate class, named XML_Data which contains the tree-building and the tree-searching methods. A 3rd class will define the nodes. As usual in these cases, the tree will exist in RAM only, not in the code. The code will have the reference to the root node and the remainder of the structure will exist in RAM only.

When the program starts, the main will instantiate the XML_Data class and it will immediately read the indicated text file and build the tree. When that task has been completed, main will communicate with the user to perform searches and retrievals of information.

Each leaf-node (lowest-level node containing a value) has an associated path. For example, in the plant catalog file, the path CATALOG.PLANT[3].PRICE will find the element $9.90 . The subscript [3] is needed because merely specifying PLANT in the path would not allow the user to distinguish between the 36 sub-elements of CATALOG.

There should be a method to search the data file and return the number of sub-elements at the location described by the path. For example, the path CATALOG will return the number 36 because there are 36 sub-elements named PLANT at that point. The path CATALOG.PLANT[12] will return the number 6 because there are 6 sub-elements of PLANT at that point. The path CATALOG.PLANT[2].COMMON will return the number 0 because COMMON at that location has no sub-elements.

There should be a second method to search the data file, find the designated element and return a String containing it and its sub-elements. For example, the path CATALOG.PLANT[3] will return a String containing the following:

Cowslip

Caltha palustris

4

Mostly Shady

$9.90

030699

The path CATALOG.PLANT[3].ZONE will return a String containing the following:

4

Your requests should be case-insensitive.

The diagram is above.

I need the ful complete answer.

CATALOG CD CD CD TITLE TITLE TITLE ARTIST ARTIST COUNTRY ARTIST COUNTRY COUNTRY COMPANY COMPANY COMPANY PRICE PRICE PRICE YEAR YEAR YEAR CATALOG CD CD CD TITLE TITLE TITLE ARTIST ARTIST COUNTRY ARTIST COUNTRY COUNTRY COMPANY COMPANY COMPANY PRICE PRICE PRICE YEAR YEAR YEAR

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 Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

7 6 .

Answered: 1 week ago

Question

Economic Convergence

Answered: 1 week ago

Question

Report on axial pumps

Answered: 1 week ago

Question

Name is needed for identifying organisms ?

Answered: 1 week ago

Question

Q.1. Taxonomic classification of peafowl, Tiger and cow ?

Answered: 1 week ago