YousefSeyam's blog

By YousefSeyam, 7 days ago, In English

Longest Increasing sub-sequence in an array starting from index i


Below is a method for finding the longest increasing sub-sequence of an array starting from an arbitrary element in the array

consider the following array A = [7 9 3 4 5 1 6 8 2 4]

say we need to find the longest sub-array such that the element Ai > Ai — 1

for example: the sequence [2 5 6 8] is said to be an increasing sequence since if you choose an arbitrary element in this sequence, all the elements after it is strictly greater than it

on the other hand, a sequence like this [3 4 7 1 4] is not an increasing sequence since it violates the previous rule. if i were to choose the number 7 for example, i would find that it's followed by the number 1 which is less than 7.

Full text and comments »

  • Vote: I like it
  • -17
  • Vote: I do not like it