Write a function named longestSortedSequence that accepts an array of integers a
ID: 3551577 • Letter: W
Question
Write a function named longestSortedSequence that accepts an array of integers as a parameter and that returns the length of the longest sorted (non-decreasing) sequence of integers in the array. For example given the sequence:
5 7 2 8 9 10 12 98 7 14 20 22
The longest sorted sequence starts on 2 and ends on 98, so the length of this sequence is 6. The sequence that starts on 7 and ends on 22 is also sorted but its length is 4 so that would not be the correct answer.
Demonstrate how your function works: call it from Main with each of the 5 following arrays
1 2 3 5 9 10 11 12
9 8 6 4 2 1 0
5 7 2 8 9 10 12 98 7 14 20 22
5 7 1 1 9 10 12 98 7 14 20 22 23 42 50 99
2
Explanation / Answer
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.