Compare commits

...

4 Commits

6 changed files with 16 additions and 11 deletions

View File

@ -80,13 +80,13 @@ def algorithmInfos(
outputs_ = outputs if isinstance(outputs, tuple) else tuple([outputs]);
outputnames_ = outputnames if isinstance(outputnames, tuple) else tuple([outputnames]);
outputsNamed = { outputnames_[k]: value for k, value in enumerate(outputs_) };
# Postchecks
if checks and callable(postChecks):
postChecks(**inputs, **outputsNamed);
# Letzte Messages
if metrics:
DisplayMetrics();
DisplayEndOfAlgorithm(**outputsNamed);
# Postchecks
if checks and callable(postChecks):
postChecks(**inputs, **outputsNamed);
except Exception as e:
nonnestedAlgorithms.state = state1;
nonnestedRecursion.state = state2;

View File

@ -58,4 +58,6 @@ def BinarySearch(L: List[int], x: int) -> int:
else: # x > L[m]
logDebug('Suche in L[m+1], L[m+2], ..., L[len(L)-1] fortsetzen, m = {}.'.format(m));
index = BinarySearch(L=L[m+1:], x=x);
return (m + 1) + index; # NOTE: muss Indexwert kompensieren
if index >= 0:
index += (m + 1); # NOTE: muss Indexwert kompensieren
return index;

View File

@ -56,7 +56,9 @@ def JumpSearchLinear(L: List[int], x: int, m: int) -> int:
if x < elementAfterBlock:
logDebug('Element muss sich im Block [{i0}, {i1}) befinden.'.format(i0 = i*m, i1 = (i+1)*m));
index = SequentialSearch(L=block, x=x);
return offset + index; # NOTE: muss wegen Offset kompensieren
if index >= 0:
index += offset; # NOTE: muss wegen Offset kompensieren
return index;
logDebug('Element befindet sich nicht im im Block [{i0}, {i1}) befinden.'.format(i0 = i*m, i1 = (i+1)*m));
i += 1;
return -1;
@ -85,7 +87,9 @@ def JumpSearchExponentiell(L: List[int], x: int) -> int:
if x < elementAfterBlock:
logDebug('Element muss sich im Block [{i0}, {i1}) befinden.'.format(i0 = i0, i1 = i1));
index = SequentialSearch(L=block, x=x);
return i0 + index; # NOTE: muss wegen Offset kompensieren
if index >= 0:
index += i0; # NOTE: muss wegen Offset kompensieren
return index;
logDebug('Element befindet sich nicht im Block [{i0}, {i1}) befinden.'.format(i0 = i0, i1 = i1));
i0 = i1;
i1 *= 2;

View File

@ -37,7 +37,7 @@ parts:
description: 'Freiwilliges ÜB2, A5a'
inputs: &ref_inputs_ueb2_5
L: [4, 11, 22, 23, 25, 27, 29, 36, 41, 52, 64, 76, 82, 86, 94, 96, 102, 117, 123, 147, 188, 211, 216, 222, 224, 226, 233, 239, 255, 263, 277, 289]
x: 117
x: 114
- command: 'algorithm-search-jump'
description: 'Freiwilliges ÜB2, A5b'
inputs:

View File

@ -88,6 +88,5 @@ if __name__ == '__main__':
try:
args = GetArgumentsFromCli(sys.argv[1:]);
except:
DisplayHelpMessage();
exit(1);
enter(quiet=args.quiet, debug=args.debug, mode=args.mode[0], path=args.path);