Algorithm analysis with advanced data structures

Assignment Help JAVA Programming
Reference no: EM1378351

Algorithm Analysis with Advanced Data Structures

Alchemy

-Mines of Oreland yield unlimited amounts of silver, but no gold. Unfortunately, rich noblemen from the neighboring kingdom of Eldorado are interested only in buying gold.

-The resourceful merchants of Oreland want to hire alchemists to change the silver into gold. However, the skills of alchemists are somewhat limited - they cannot transmute any metal into any other, so the process of changing silver into gold may have to go through a sequence of transmutations involving other metals.

-For each transmutation, alchemists charge a fee, which depends on the pairs of metals involved in the transmutation.

-Your task is to write a program to help the merchants devise a sequence of transmutations that would change silver into gold with the smallest possible total fee paid to the alchemists.

Details

-Your program should read input from System.in:

-in the first line of input: a number of transmutations alchemists know how to handle

-for each transmutation the alchemists know: the metals it involves and its cost, as a triple, each in a separate line of input:

MetalX MetalY CostXY where:

-MetalX is the atomic number of the input (substrate) metal
-MetalY is the atomic number of the output (product) metal
-CostXY is the fee alchemists charge for transmuting 1 pound of MetalX into 1 pound of MetalY
-Your task is to find the sequence of transmutations, starting with silver (Ag, atomic number 47) and ending with gold (Au, atomic number 79), that has the smallest sum of fees for transmuting 1 pound of Ag into 1 pound of Au
-Your program should just return on System.out one number: the smallest possible sum of fees (it should not return the actual sequence)
-There will always be at least one way to change silver into gold

-Correct output: 9

Example
-Input:
10
47 28 5
28 29 3
26 79 6
28 26 2
79 26 4
28 79 9
26 47 7
29 28 2
47 29 10
29 79 1

-The sequence behind this correct output is (but your program shouldn't print it): 47,28,29,79 (that is: silver, nickel, copper, gold) 

Reference no: EM1378351

Questions Cloud

Provide example of next process customer : For each of the worker positions given below give an example of the next process consumer. Also provide an example in which the listed worker would be the next process consumer:
Calculate cost of equity using capm : Calculate cost of equity using CAPM. Use the rate on the 30-year T-bill for the risk free. Use 5.2% for the market risk premium - Calculate the intrinsic value of the stock using the one-stage dividend growth model
Question about negotiation : There is a made up meeting in Samuel Adams Peyton Randolph, John Randolph and Lord Dunmore John Murray to debate the ramifications of independance of the colonies from Great Britian.
Solving problem with telling everything she knows : Kate is a wonderful accountant and she just has a difficulty with telling "everything she knows." You discovered this out quite by accident.
Algorithm analysis with advanced data structures : Write a program to help the merchants devise a sequence of transmutations that would change silver into gold with the smallest possible total fee paid to the alchemists.
The representativeness heuristic : Your department was just given a new assignment to pilot and rollout to your company. The assignment involves assembling a cross-organizational team that will be given the responsibility for analyzing different payroll systems that Faraday Enterprise..
Question about random numbers for simulation : The number of cars reaching at Joe Kelly's oil change and tune up place during the last two hundred hours of operation is observed to be the following:
Model the expression for total revenue : The relationship d= 5000-25p explains what happens to demand as price varies. Here, price can vary between $10 and $50.
Woman affect the reader''s overall impression of willy : Is Willy a likeable character? What words and actions--both Willy's and those of other characters--help the reader form this conclusion and how does the existence of The Woman affect the reader's overall impression of Willy? What does she reveal a..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Implementation activities of software development

Analysis, design, and implementation activities of software development

  Prepare address book java application

Prepare an application that reads the contents of your address book file and prepare a user guide that includes a description of the functionality of your overall address book system.

  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.

  Develop a reliable transfer protocol over udp

Develop a reliable transfer protocol over UDP. Focus on a Stop- and-Wait protocol.

  Java method that contains code to be executed

Write a short Java method that contains code for which it is probably impossible for that code to ever be executed, but your favorite Java compiler does not detect this fact.

  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.

  Write specifications for method which advances date by one

Write specifications for the method which advances any given date by one day. Comprise a statement of purpose, pre- and post-conditions, and description of parameters.

  Write program in java to calculate interest

Write a program in java to do the following : the following data is stored for each customer in the bank: account number,average balance and number of transaction for each customer it is required to calculate the interest earn

  Write an interface for an abstract method

Write an interface, PointingDevice, containing:  an abstract method, getXCoord that returns an int and an abstract method, getYCoord that returns an int.

  Write a java class

Write a Java class called PQueue that extends the provided abstract QueueADT class.

  Loops and files

Convert an algorithm using control structures into Java and write a while loop

  Implement a fish-lake simulation

Implement a Fish/Lake simulation similar to the previous assignment. You will then make adjustments to accommodate class hierarchies and make use of inheritance as well as a JAVA interface.

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