Can sorting the array be a valid strategy in finding the Longest Increasing Subsequence (LIS)? Group of answer choices Yes No \
Added by Sean K.
Step 1
The LIS of an array is a subsequence that is strictly increasing and has the maximum possible length. Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 79 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Consider the following refined notion of bitonicity. Call a sequence S = [s1, s2, ..., sn] an initially increasing bitonic sequence if there is an index 1 ≤ i ≤ n such that s1 < s2 < ... < si and si > si+1 > ... > sn. On the other hand, call S an initially decreasing bitonic sequence if there is an index 1 ≤ j ≤ n such that s1 > s2 > ... > sj and sj < sj+1 < ... < sn. S is bitonic if it is either initially increasing or initially decreasing and bitonic. Given a sequence A, we would like to determine its longest bitonic subsequence. (a) (5 pts) Find a longest bitonic subsequence of the sequence A = [5, 8, 8, 3, 4, 1, 7, -3, 2, 9, 12]. Show your work. (b) (15 pts) Describe the optimal substructure of this problem. In particular, define the longest bitonic subsequence of A in terms of the solution for shorter sequences. You may assume that we have a solution for the longest increasing subsequence problem. Justify your answer. (c) (10 pts) Write pseudocode for a function LBS(A) which returns the length of a longest bitonic subsequence of A. You are given a function LIS(A) that returns a list L that is the same length as A such that L[i] is the length of the longest increasing subsequence of A ending at index i. (d) (5 pts) Analyze the asymptotic run time of your algorithm.
Akash M.
#include <stdio.h> int findLIS(int n, int s[]) { } int main() { return 0; } A subsequence is created by deleting zero or more elements from a sequence while maintaining order. A sequence is strictly increasing if every element in the sequence is greater than the previous element. For example, [1, 2, 3] is strictly increasing while [1, 22] is not. Given an array of integers, determine the length of the longest strictly increasing subsequence. For example, for the array s = [1, 2, 23, 1, 6], there are two strictly increasing subsequences: [1, 2, 3] and [1, 3, 6]. The longest increasing subsequence has a length of 4: [1, 2, 3, 6]. Function Description: Complete the function findLIS in the editor above. findLIS has the following parameter(s): - int n: the length of the array s - int s[n]: an array of integers Returns: - int: the length of the longest strictly increasing subsequence
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD