Description Write the code for the function find_sub which takes as parameter a list input_list and finds the sub-list with the maximum sum inside the list. For example, given the list [-3, -2, 5, 2, -7], the sub-list with the largest sum is [5, 2] with the sum 7. The list is to be taken from the user. In the script, input part is handled for you, along with formatting, so you don't need to do anything about it. You must use the variable Ist. It is assigned the list you will work with. The function is also called at the end, you must handle the printing inside the function. The input list will always be one dimensional, it will contain only valid float or integer elements; but an empty list can be given as input, in which case you should print an empty list as output, like in the examples. If there is an equality of maximum sum, print the first occurring sub-list. Check the examples for further clarification. Keep in mind that we will be grading your code not just based on these examples, but other cases as well, so try to write code which can handle all possible cases. You are encouraged to check the code we provided, something called list comprehension is used in it. You are not responsible from it, but it is something used to build lists on the fly. Definition: A sub-list is a list within the input list which contains contiguous elements. For example, given the list [-3, -2, 5, 2, -7], [-3, -2, 5] is a sub-list but [-3, -2, 2] is not because -3 and 2 are not next to each other in the given list.
Description Write the code for the function find_sub which takes as parameter a list input_list and finds the sub-list with the maximum sum inside the list. For example, given the list [-3, -2, 5, 2, -7], the sub-list with the largest sum is [5, 2] with the sum 7. The list is to be taken from the user. In the script, input part is handled for you, along with formatting, so you don't need to do anything about it. You must use the variable Ist. It is assigned the list you will work with. The function is also called at the end, you must handle the printing inside the function. The input list will always be one dimensional, it will contain only valid float or integer elements; but an empty list can be given as input, in which case you should print an empty list as output, like in the examples. If there is an equality of maximum sum, print the first occurring sub-list. Check the examples for further clarification. Keep in mind that we will be grading your code not just based on these examples, but other cases as well, so try to write code which can handle all possible cases. You are encouraged to check the code we provided, something called list comprehension is used in it. You are not responsible from it, but it is something used to build lists on the fly. Definition: A sub-list is a list within the input list which contains contiguous elements. For example, given the list [-3, -2, 5, 2, -7], [-3, -2, 5] is a sub-list but [-3, -2, 2] is not because -3 and 2 are not next to each other in the given list.
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18PE
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning