Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are given a sequence of numbers in an array A = [0, 8, 2, 12, 4, 10, 6, 14,

ID: 3673869 • Letter: Y

Question

You are given a sequence of numbers in an array A = [0, 8, 2, 12, 4, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15]. Let L = L[1], ..., L[16] be an array of size 16 such that L[i] stores the length of the longest increasing subsequence of A that ends with A[i]. Solve the following:

Fill the entries of L below. (Use Length-LIS algorithm)

Length-LIS(A, n)

- For i = 1 to n {

- max ? 1

- For j = 1 to (i ? 1) {

- If (A[j] < A[i]) {

- If (max < L[j] + 1) max ? L[j] + 1

}

- L[i] ? max

}

}

- return the maximum of L[i]’s

6 7 8 10 11 1213 14 15 16

Explanation / Answer

L = [1, 2, 2, 3, 2, 3, 3, 4, 2, 4, 3, 5, 3, 5, 4, 6]

LOngest increasing subsequence:
0, 2, 6, 9, 11, 15

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote