Computer Science

IT Matura Course | Algorithms #15


categories: computer science

Welcome,
Below you will find a video with a detailed explanation of the algorithm for determining the length of the longest contiguous non-decreasing subsequence. Its operation, time complexity, and usefulness. Below you will also find ready-to-use code that you can copy if needed.
Code:


tablica = [1, 4, 2, 3, 6, 7, 9, 10]

def podciag(tab):
    dlugosc = len(tab)
    max = -1000
    wskaznik = 0
    for i in range(len(tab)):
        if wskaznik < i:
            wskaznik = i
            while wskaznik < dlugosc - 1 and tab[wskaznik] <= tab[wskaznik + 1]:
                wskaznik += 1
            zmiennaDl = wskaznik - i + 1
            if zmiennaDl > max:
                max = zmiennaDl
        wskaznik = 0
    return max

print(podciag(tablica))
                  

Video:

Thank you for reading!


Read more
Administrator

This post was written by the administrator

Recent Posts

Proof Problems in Mathematics The Beginning Integrals, Course Practical Physics for Engineers IT Matura Course | Algorithms IT Matura Course | Databases IT Matura Course | Theory IT Matura Course | Spreadsheet

Archive

Year 2022

Comments