forked from hofmannol/AlgoDatSoSe25
Added and fixed Comments
This commit is contained in:
parent
79f0fc36fd
commit
364590c563
@ -39,7 +39,7 @@ def max_sequence_2(z: MemoryArray):
|
|||||||
return m, l, r
|
return m, l, r
|
||||||
|
|
||||||
def _max_sequence_3_sub(z: MemoryArray, l: Literal, m: Literal, r: Literal):
|
def _max_sequence_3_sub(z: MemoryArray, l: Literal, m: Literal, r: Literal):
|
||||||
# find max-sum from Middle to left (including on elem from right)
|
# find max-sum from Middle to left
|
||||||
linksMax = MemoryCell(MIN_VALUE)
|
linksMax = MemoryCell(MIN_VALUE)
|
||||||
sum = MemoryCell(0)
|
sum = MemoryCell(0)
|
||||||
links = MemoryCell(l)
|
links = MemoryCell(l)
|
||||||
@ -50,7 +50,7 @@ def _max_sequence_3_sub(z: MemoryArray, l: Literal, m: Literal, r: Literal):
|
|||||||
linksMax.set(sum)
|
linksMax.set(sum)
|
||||||
links.set(i)
|
links.set(i)
|
||||||
|
|
||||||
# find max-sum from Middle to right (inluding one elem from left)
|
# find max-sum from Middle to right
|
||||||
rechtsMax = MemoryCell(MIN_VALUE)
|
rechtsMax = MemoryCell(MIN_VALUE)
|
||||||
sum.set(0);
|
sum.set(0);
|
||||||
startRight = MemoryCell(1) + m
|
startRight = MemoryCell(1) + m
|
||||||
@ -114,6 +114,7 @@ def max_sequence_4(z: MemoryArray):
|
|||||||
max.set(aktSum)
|
max.set(aktSum)
|
||||||
links.set(aktLinks)
|
links.set(aktLinks)
|
||||||
rechts.set(i)
|
rechts.set(i)
|
||||||
|
# if negative we start new Sum -> Restart must be better than continue
|
||||||
if aktSum < Literal(0):
|
if aktSum < Literal(0):
|
||||||
aktSum.set(0)
|
aktSum.set(0)
|
||||||
aktLinks.set(MemoryCell(1) + i)
|
aktLinks.set(MemoryCell(1) + i)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user