logo

Crowdly

Mis keerukusega on järgnev algoritm? def seljakott(a, k): if len(a) == 0 ...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Mis keerukusega on järgnev algoritm?

def seljakott(a, k):

if len(a) == 0 or k <= 0:

return []

a0 = [a[0]] + seljakott(a[1:], k-a[0])

a1 = seljakott(a[1:], k)

s0 = sum(a0)

s1 = sum(a1)

if s0 > k or s1 > s0:

return a1

return a0

More questions like this

Want instant access to all verified answers on moodle.ut.ee?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!