Question: Need help with 1-4: Consider the following problem: Input: An array A[1n] of integers Output: The largest integer m such that the array A[1n] has
Need help with 1-4:
![Need help with 1-4: Consider the following problem: Input: An array A[1n]](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2e63e4aed0_68566f2e63db65a4.jpg)
![of integers Output: The largest integer m such that the array A[1n]](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2e63f5e7ea_68666f2e63ebe997.jpg)
Consider the following problem: Input: An array A[1n] of integers Output: The largest integer m such that the array A[1n] has subsequence of length m which is strictly increasing. The following pseudocode finds the length of the longest of the given array A[1n] by considering all possible subsequences: \begin{tabular}{l} \hline Algorithm 1 longestSubSeq( int A[1n] ) \\ \hline 1:k=0; \\ 2: while (true) do \\ 3: //(I) The longest increasing subsequence of A has length nk \\ 4: do \\ 5: Let B=A with k of its elements removed \\ 6: if ( isIncreasing (B)) then \\ 7: return nk; \\ 8: end if \\ 9: while ( there are other untested choices of k elements to remove ) \\ 10: k++; \\ 11: end while \end{tabular} The following code checks if an array is increasing (i.e., each number is smaller than the next in the array). \begin{tabular}{l} \hline Algorithm 2 isIncreasing( int C[1n]) \\ \hline 1:i=1; \\ 2: while i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
