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

  Java program for line item application

This exercise explains you the process of testing and enhancing Line Item application. Open LineItemApp, Validator, Product, LineItem, and ProductDB classes that are in the c:java1.6ch06LineItem directory and review this code.

  File integrity checker - tripwire

Write a program that will perform some of the basic tasks accomplished by a file integrity checker such as Tripwire.

  Determine if strings are equal

Complete the recursive method match in the code below which will determine whether or not two strings match.

  Write java programming to show number of credits for course

Write the java programming to solve following problem. We are given a student's marks in Calculus 1, CS1, and Physics 1 (each mark being between 0 and 100) also number of credits for each course.

  Prepare a program that constructs a binary tree

Write your own implementation of primitive operations and use self-referential classes in your implementation.

  Distributed systems

Build robust, secure distributed systems using advanced programming techniques

  Create a project in eclipse

Create a new project

  Write java program to print strings given at command line

Write a program Average.java which just prints strings that it is given at command line, one per line. If nothing is given at command line, print "No arguments".

  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.

  Write a java application to ask number of assignments

Write a java application that accomplishes the following tasks with built in exception handling: ask the number of homework assignment students have submitted in a semester

  Implementation the two classes

Program Specifications: In the new implementation, the two classes, Student and Grades, are defined with the following operations/methods.

  Creating the gui for the game interface

A GUI-based application that allows a user to play a simple trivia game

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