CS286 -- Lab 4: Graphs



->Courses
->CS286
-->Homework
-->Quiz 1
-->Lab 1
-->Lab 2
-->Lab 3
->Lab 4
->Electronic Submission
->MSVC++ Info
->STL Info
->MFC/GUI Info
->Tentative Schedule
->Course Policies

[Courses]
[Unix][Home][Photos]
[PHome]

Spring Quarter 2000

Purpose

This lab assignment is designed to provide exposure to one application of graph theory. Upon completion of the assignment, students should have a better understanding of how graphs may be represented and manipulated within a software system.

Assignment

Currency exchange rates may be used to earn money. The idea is to transform currency through a series of exchanges that begin and end with the same currency and result in greater amount of currency than the initial amount. For example, suppose 1 U.S. dollar buys 12 pesos, 1 peso buys 0.2 francs, and 1 franc buys 0.5 U.S. dollars. The result of converting 1 U.S. dollar to pesos, then to francs, and then back to U.S. dollars, is 1.20 U.S. dollars... a 20% profit. This process is known as Arbitrage.

Appropriately timing the market allows currency traders to turn a profit. Unfortunately for the currency trader, each transaction usually requires a trading fee. For simplicity, you should assume a 1% fee for all trades in this assignment.

Three files are available currency.txt, exchange.sml, and exchange.lrg. The first file contains a key for the abbreviations used in the other two files. The other two files contain exchange rates for a number of countries. The first and last lines may be ignored. All of the remaining lines describe one exchange rate. For example,

  MYR -> USD [label="0.263227"];
indicates that 1 Malaysia ringgit is worth 0.263227 U.S. dollars. Note, these rates do not include the 1% trading fee. Accounting for the fee, 1 Malaysia ringgit could be converted to (1*0.99*0.263227) = 0.257989 U.S. dollars.

The exchange.lrg file indicates the exchange rates between many currencies for the most recent strictly odd date in history (11/29/1999). I have modified a number of exchange rates in order to make this lab assignment more interesting. The exchange.sml file contains a subset of the exchange rates listed in exchange.lrg.

You have been given 10,000 virtual U.S. dollars. Develop a program that efficiently finds the sequence of trades that produce the highest profit. Your sequence must not pass through any currency more than once (with the exception that it must begin an end with U.S. dollars). This sequence should be stored in a file along with the percent profit. Execute your program on both exchange files.

Lab report (due 11:00pm, the day of week 10 lab)

The lab report need not be self-contained. Instead, your report should give a complete description of the algorithm designed to find the optimal trading sequence. Your report should include:

  • Algorithm description
  • Time complexity analysis for your algorithm
  • Documented source code
  • CSP level 2.0 documentation (this may be submitted in hardcopy at the beginning of lab)
  • Narrative (what you learned, suggestions of how the lab could have been better, things you would have done differently, reactions to the value of CSP, etc.)

As with any report you submit, correct spelling and grammar are required. In addition, your report should be submitted electronically following the Electronic Submission Guidelines. (You may wish to consult the sample report before submitting your report.) Be sure to keep copies of all your files, in case something gets lost. It may be wise to keep a diskette backup as well.

If you have any questions, consult the instructor.

Office: CC-27C, Phone: 277-7339
Last Updated: April 24, 2000
© 2000 Dr. Christopher C. Taylor