Question: Could someone please help me solve these two problems? Expected Behavior Write a function longest_sorted_sequence (tup) that takes the tuple tup consisting of all integers
Could someone please help me solve these two problems?


Expected Behavior Write a function longest_sorted_sequence (tup) that takes the tuple tup consisting of all integers as a parameter and returns the length of the longest sorted (nondecreasing) sequence of values in the tuple. For example, given the tuple of integers below (2, 4, 6, 1, 7, -2, , 14, se, 5, 98, 12) the function would return 4, since the longest sequence of values in increasing order has length 4 (the sequence -2, 0, 14, 30). Also, notice that two consecutive integers of the same value are sorted, since they are nondecreasing. That means that the sequance can contain duplicates. For example, given the tuple of integers balow (12, 15, 8, 2, 6, 6, 6, 8, 2, 4, 6, 1, 13) the function would return 5 since the longest sequence of nondecreasing values is 2. 6, 6.6, 8 If the function is passed an empty tuple, the function should return 0. If the function is passed a tuple of one element or consists of an entirely decreasing sequence of values, the function should return 1 Programming Requirements You may not use any additional data structures to solve this problem Examples 1. longest sorted_sequence((2, 4, 6, 1, 7,-2, e, 14, 3e, 5, 98, 12)) Return value: 4 2. d longest sorted_sequence (12, 15, 8, 2, 6, 6, 6, 8, 2, 4, 6, 1, 13) 3. longest sorted_sequence(tuple 4. longest_sorted_sequence(4,3,2,1) Return value: 5 Return value: 0 Return value: 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
