Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(10 points) Longest Increasing Subsequence. In the longest increasing subsequence problem, you are given as input an unsorted array A of length n, e.g A-5,2,10,

image text in transcribed

(10 points) Longest Increasing Subsequence. In the longest increasing subsequence problem, you are given as input an unsorted array A of length n, e.g A-5,2,10, 3,-1,6,8,9, 3 The goal is to find the longest strictly increasing subsequence of A. The subsequence need not be continguous. For example, the boxed numbers below indicate the longest increasing subsequence in our exaimple: To approach this problem, it is first helpful to define a "helper" function LIS(j) to compute the length of the longest increasing subsequence that ends at index j (and includes item Alj]). Here are examples or j 3 and j-i5: 5, 2105,2, 10,3, -1 Therefore LIS(3) should return 2, and LIS(5) should return 1. a) Write a recursive algorithm for LIS(j) (b) Translate this recursive algorithm into a recurrence. Define OPT(j) to be the length of the longest increasing subsequence ending at index j, and write a recurrence for OPT(j) in the array entry Mj] for all j (ending at any j) (c) Use this recurrence to write an iterative algorithm to compute the value of OPT(j) and store it (d) Use the computed optimal values to find the value of the overall longest increasing subsequence (10 points) Longest Increasing Subsequence. In the longest increasing subsequence problem, you are given as input an unsorted array A of length n, e.g A-5,2,10, 3,-1,6,8,9, 3 The goal is to find the longest strictly increasing subsequence of A. The subsequence need not be continguous. For example, the boxed numbers below indicate the longest increasing subsequence in our exaimple: To approach this problem, it is first helpful to define a "helper" function LIS(j) to compute the length of the longest increasing subsequence that ends at index j (and includes item Alj]). Here are examples or j 3 and j-i5: 5, 2105,2, 10,3, -1 Therefore LIS(3) should return 2, and LIS(5) should return 1. a) Write a recursive algorithm for LIS(j) (b) Translate this recursive algorithm into a recurrence. Define OPT(j) to be the length of the longest increasing subsequence ending at index j, and write a recurrence for OPT(j) in the array entry Mj] for all j (ending at any j) (c) Use this recurrence to write an iterative algorithm to compute the value of OPT(j) and store it (d) Use the computed optimal values to find the value of the overall longest increasing subsequence

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions

Question

Are there fewer of them to do it (i.e., have you been downsizing)?

Answered: 1 week ago