Question
Create a program that will read the data for a two-dimensional integer array from a file. Using this array, your program is to determine the
Create a program that will read the data for a two-dimensional integer array from a file. Using this array, your program is to determine the longest increasing path within the array starting from an arbitrary starting point that is, the longest path can start from any element within the array. Additionally, your program will find the longest incrementally increasing path within the array starting from an arbitrary starting point. In the event that two longest paths exist (both the same length), the path with the highest total value of elements will be selected.
An increasing path is one in which the subsequent value in the path is always larger than its predecessor (example 2 4 5 8 12 20). An incrementally increasing path is one in which the subsequent value in the path is exactly one larger than its predecessor (example 3 4 5 6). For both, only moves up, down, left and right are permitted.
Several test data files are provided to help you test your program. Sample output for the first two files are shown below. Format your output to match these samples.
*** here is the out put *** it should be the same
Enter name of problem file: testData1.txt
[ 3, 4, 5] [ 9, 6, 7] [ 2, 1, 8]
The longest increasing path with maximum total is: 3-4-6-7-8
The length of this path is 5 and the total of the values is 28.
The longest incrementally increasing path with maximum total is: 6-7-8
The length of this path is 3 and the total of the values is 21.
testData1.txt 3 4 5 9 6 7 2 1 8Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started