Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
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