Question: 5. Write a program, LongestPlateau.java, that reads an array from a file and then finds the length of the longest plateau in the array. A

 5. Write a program, LongestPlateau.java, that reads an array from a

5. Write a program, LongestPlateau.java, that reads an array from a file and then finds the length of the longest plateau in the array. A plateau is a segment whose elements are all equal. For example, in the array [3, 8,8, 8,9,-14, -3,-3, -3, -3, 56, 98, 12] the longest plateau consists of four values, so your program should print 4 if passed this array. Each line of the file contains a single array, where the first integer of each line defines the size of the array (n), followed by the n elements of the array. Sample Run: plateau.txt 6 5 6 3 11 5 13 3 8 8 8 9 -14-3-3-3-3 Output 2 Spring 2017-18 1 of 3 Introduction to Computer Programming (CMPS 200) Now write a second program LongestPlateauSorted.java, where you assume that the sequence of integers is sorted in non-decreasing order. You must use the assumption of sortedness to simplify the program and make your solution more efficient

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!