Greatest Path Sum in Triangle (due 07 August 2013)

This assignment is a variation of a problem from Project Euler. You are required to find the greatest path sum starting at the top of the triangle and moving only to adjacent numbers on the row below.

  7 4
 2 4 6
8 5 9 3
In the above triangle, the maximum path sum is 3 + 7 + 4 + 9 = 23.

You will read your input from the file triangle.txt . The first line indicates n the number of rows in the triangle. This will be followed by n lines of data. Each line of data will have only positive integers greater than 0. The first line of data in the triangle will have 1 number, the second line in the triangle will have 2 numbers and so on. The nth line will have n integers.

You will have a single line of output:

The greatest path sum is 23.

For this assignment, we are strongly recommending that you work with a partner. Both of you will have to read the paper on Pair Programming . The two of you will jointly work on this assignment and submit a single copy of the assignment with both your names on it.

The file that you will be submitting will be called Your solution has to be recursive. You will choose a data structure that will be appropriate to solve this problem. You will follow the standard Java coding convention that I have appended below. The file will have a header of the following form:



  Student Name:

  Student UT EID:

  Partner Name:

  Partner UT EID:

  Course Name: CS 312

  Unique Number: 

  Date Created:

  Date Last Modified:


You will follow the standard Java Coding Conventions. You can either view the HTML page or download the PDF or Postscript and print it out. There is a modification that I would like to make to the standard coding conventions. Please align the opening and closing braces vertically so that you can easily make out the blocks of code. For example:

Do this:
if ( x > 5 )
  a = b + c;

Not this:
if ( x > 5 ) {
  a = b + c;

Use the turnin program to submit your file. We should receive your work by 11 PM on Wednesday, 07 August 2013. There will be substantial penalties if you do not adhere to the guidelines.