Implementing dijkstras shortest-path algorithm

Assignment Help JAVA Programming
Reference no: EM13720963

Question 1. Your program should start by reading in the data-file, cities.txt, that has been provided.

This file contains a set of several hundred major cities, along with their longitude and latitude, in degrees. Your program should create a weighted graph structure: in the graph, each vertex stores a single city, and cities that are less than 2000 miles apart are connected to one another by edges, representing a direct flight between the cities, where each edge also has a weight equal to the distance between the cities. For distance calculations, we will use the Haversine Formula, which can take in two points on the globe and give the distance between them.

You should write code to do this calculation, returning the distance in miles between two points as a double value. (Note: for this to work, the inputs to any of the trigonometry functions must be in the form of radians, not degrees. All of the methods you need for this calculation can be found in the Math class.)

Question 2. Once the graph is created, the program should prompt the user for pairs of cities. If the two cities are found in the graph, then it should run a version of Dijkstra's algorithm to find the shortest path between them (many of these paths are quite indirect, since the graph assumes that no direct flight of longer than 2000 miles is possible). The code should continue prompting the user for input until they enter "Q" to quit. If the user enters anything that is not a city in the graph, then the process should start again, asking for a new pair of cities.

When it finds a route between the two cities, it should return that route, along with its total length in miles (truncated to an integer value for output purposes).

For precise output format and behavior, see the demonstration videos that were posted with this assignment, or the sample run included with this document.

Question 3. To improve efficiency of the program, you should add some caching to it. That is, if a user searches more than once for a route between one pair of cities during a single run of the program, it should not re-compute that route using Dijkstra's algorithm. Instead, it should save all search results that it has generated as it goes, and if asked for one that it has already performed, simply return that path.

Reference no: EM13720963

Questions Cloud

What is the jet centripetal acceleration : A jet fighter flying at 300 m/s (just below the speed of sound) makes a turn of radius 2.65km. What is its centripetal acceleration in gs
Prepare a 2012 taxable income statement table : Prepare a 2012 taxable income statement table for the partnership for 2012 - taxable income partnership income statement include the land sale total gain and allocate this gain to the partners
Snells lam of refraction by tracing the direction : Verify Snell's Lam of refraction by tracing and measuring the direction of refracted light rays through a change in medium. If we replaced the water dish with a solid glass disk of the same shape, explain how your data would be different
Describe a plan of action for implementing the strategy : What are the most important elements of a plan of action for implementing the strategy
Implementing dijkstras shortest-path algorithm : Implementing Dijkstras shortest-path algorithm - To improve efficiency of the program, you should add some caching to it
Responsibility to successfully completing treatment goals : Reflect on a treatment plan for yourself as a drug counselor. Identify services you could use to meet your goals as a drug counselor. What is your responsibility in achieving your goal? How is this similar to your clients' responsibility to succes..
Presentation for the executive staff or board of directors : You are an executive for Oprah Enterprise and you are preparing a presentation for the executive staff or board of directors about the organization's direction.
Identify two technological innovations : Identify two (2) technological innovations that have changed the fundamental manner in which companies have conducted business over the last 20 years, and recognize one (1) aspect of each that has impacted your own career. What piece of technology..
Prepare paper on prevention of maritime terrorism : Prepare paper on Prevention of Maritime Terrorism: The Container Security Initiative

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd