Menu

[Solved]8 Objectives Assignment Enhance Knowledge Skill Java Gain Understanding Experience Heaps P Q37204488

8. The objectives of this assignment are to:

  1. Further enhance your knowledge and skill in Java.
  2. Gain an understanding and experience with heaps and priorityqueues.
  3. Gain further experience using generics.
  4. Gain further experience in using Javadoc documentation.
  5. Continue to practice good programming techniques.

Background

To study a particular astronomical phenomenon or to evaluate atheory, astronomers may want to determine the k nearestentities to a point in space. This could be accomplished bycalculating the distance of each entity from the point and sortingthem by that distance. Unfortunately, the best sorting algorithmsare O(n log n) and there may be hundreds ofthousands of astronomical entities to be considered. Since only thek-nearest entities are needed, it is a waste ofcomputation to sort all entities. Instead, we can placethem in a min heap (based on distance) and then remove the firstk items. Adding n items with each enqueuerequiring O(log n) results in a complexity of O(nlog n). However, the heap does not require sorting allelements and will, therefore, require less processing time.

Project

Create a heap class named Heap that stores generics with thefollowing methods below. Implement the priority queue using a minheap. Write a test program that thoroughly tests your binary searchtree implementation.

boolean enqueue(E item)

adds item to the tree

returns true if enqueue was successful

E dequeue()

remove the root node

returns the item in the root, or null if heap is empty

Once the Heap class is working, create a class AstroReport thatidentifies the k -nearest astronomical entities to a pointin space. To simplify the task, we will only consider stars on a2-dimensional grid, rather than the actual 3-dimensional space. Therun() method will ask the user for a point in space, identified byx and y coordinates, and the number of nearestneighbors desired. It will then read astronomical objectinformation from a file, named astro.txt, one item at a time,calculate its Euclidean distance from the point of interest, createan Astro object, and place it in the heap. The heap is ordered bydistance. The astro.txt file contains the following space-delimitedfields:

Fields

Description

name

String

xCoord

integer – x coordinate

yCoord

integer – y coordinate

The method will output the coordinates of the specified point inspace followed by the k nearest neighbors. The nearestneighbor information should include the star name, x and ycoordinates, and distance to the desired point in tabularformat.

Requirements

  • Your source code should use proper object-oriented style. Thatis, the main program should only instantiate a class which displaysand processes the menu.
  • Your source code should be documented using Javadoc styleaccording to the course standards.
  • Follow good programming practices.
  • Use the default package in your project; do not specify apackage in your code.

astro.txt

Achernar 537 272Alcor 970 25Aldebaran 737 356Algol 900 325Almagest 990 235Alpha-Centauri 155 99Altair 450 650Antares 647 754Arcturus 964 579Belltrix 545 192Beta-Cassiopia 378 525Betelgeuse 412 377Canopus 218 150Capella 424 9Delta-Cygnus 42 472Deneb 218 8Epsilon-Ceti 271 471Epsilon-Cygnus 25 458Fomalhaut 437 856Gamma-Centauri 158 112Gamma-Cygnus 56 471Groombridge 996 904Hyperion 656 127Menkar 481 927Metis 570 460Microscopii 439 998Mizar 41 130Mu-Draconis 231 870Organon 685 58Pollux 565 9Procyon 74 227Regulus 373 106Rigel 210 208Siris 180 151Sol 175 145Theta-Persei 937 241Vega 33 975Vela 334 193Zeeman 335 194Zeta-Ptolemae 179 34

Expert Answer


Answer to 8. The objectives of this assignment are to: Further enhance your knowledge and skill in Java. Gain an understanding and… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *