• or if Zi > Zi+1 it must be th

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

In class we showed how to calculate the longest increasing subsequence. This requirement turned out too
strict and we are interested to finding the longest close-to-increasing subsequence.
We say that a sequence of numbers Z is close-to-increasing if the size of any decreasing substring is at
most 2. So given two consecutive elements in the sequence Zi and Zi+1 it must either be that
• Zi < Zi+1
• or if Zi > Zi+1 it must be that Zi+1 < Zi+2.
Below are some examples of of close-to-increasing sequences:
A = 11 10 18 17 25 33 30 34 27 29
B = 8 99 33 34 40 11 13 20 23 22
As we can see A2 = 10 < 11 = A1 but A3 = 12 > 10 = A2 so the constraint is satisfied. Same is true in
other places where monotonicity fails at A7, A11, A14. Similar for sequence B.
The following are examples of sequences that are not close-to-increasing:
C = 10 11 13 12 18 30 27 22 33 40 44
D = 17 16 1 11 13 12 15 19 30 25 33
We have C6 = 30 > 27 = C7 and C6 = 27 > 22 = C9 so the constraint is violated. Similarly D1 > D2 > D3 so
the sequence D is not close-to-increasing. For example if X = D the longest close-to-increasing subsequence
is Z = 17, 1, 11, 13, 12, 15, 19, 30, 25, 33 for a size of 11. You may assume all numbers in X are unique.
a. (25 points) Give a dynamic programming algorithm using the following optimal subproblem structure
LCIS+(i, j) : is the longest closed to increasing subsequence that ends and XiXj , i.e., its last element
is Xj and its second to last element is Xi
. Give a recursive formula, prove its correctness and write a
bottom-up implementation.
b. (15 points) Give a dynamic programming algorithm using the following optimal subproblem structure
LCIS+(i) is the longest closed to increasing subsequence that ends and Xi and the auxiliary optimal
subproblem structure LCIS+,inc(i) is the longest closed to increasing subsequence that ends at Xi
in
an increasing fashion (the second to last element is smaller than Xi). Give a recursive formula for both
optimal subproblem structures, prove their correctness and write a bottom-up implementation. 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY