Question
Given an integer array, design a dynamic programming algorithm to find the length of the longestincreasing sub-array. The elements of the sub-array should be consecutive
Given an integer array, design a dynamic programming algorithm to find the length of the longestincreasing sub-array. The elements of the sub-array should be consecutive in the main array. Make sureyour algorithm does not compute the sub-problems which had been computed before.
Example:Input: [1, 4, 5, 2, 4, 3, 6, 7, 1, 2, 3, 4, 7]
Output: 5 (the sub-array is [1, 2, 3, 4, 7])
Example:Input: [1, 2, 3, 4, 1, 2, 3, 5, 2, 3, 4]
Output: 4 (the sub-array is [1, 2, 3, 4] or [1, 2, 3, 5])
PS: Printing the sub-array is not mandatory.
Whenever you are asked to design an algorithm, implement your solution inPython3. Write a driver function to test each of these algorithms. Inputs shouldbe randomly generated (by usingrandomlibrary) or taken from the user (you mayassume that the inputs are proper)
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