Compare commits
No commits in common. "965cd48ae6b334937e6f3e667c02628959844544" and "ab2473af9e6058a2faa051029bd071abe156b71c" have entirely different histories.
965cd48ae6
...
ab2473af9e
@ -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;
|
||||
|
@ -58,6 +58,4 @@ 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);
|
||||
if index >= 0:
|
||||
index += (m + 1); # NOTE: muss Indexwert kompensieren
|
||||
return index;
|
||||
return (m + 1) + index; # NOTE: muss Indexwert kompensieren
|
||||
|
@ -56,9 +56,7 @@ 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);
|
||||
if index >= 0:
|
||||
index += offset; # NOTE: muss wegen Offset kompensieren
|
||||
return index;
|
||||
return offset + index; # NOTE: muss wegen Offset kompensieren
|
||||
logDebug('Element befindet sich nicht im im Block [{i0}, {i1}) befinden.'.format(i0 = i*m, i1 = (i+1)*m));
|
||||
i += 1;
|
||||
return -1;
|
||||
@ -87,9 +85,7 @@ 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);
|
||||
if index >= 0:
|
||||
index += i0; # NOTE: muss wegen Offset kompensieren
|
||||
return index;
|
||||
return i0 + index; # NOTE: muss wegen Offset kompensieren
|
||||
logDebug('Element befindet sich nicht im Block [{i0}, {i1}) befinden.'.format(i0 = i0, i1 = i1));
|
||||
i0 = i1;
|
||||
i1 *= 2;
|
||||
|
@ -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: 114
|
||||
x: 117
|
||||
- command: 'algorithm-search-jump'
|
||||
description: 'Freiwilliges ÜB2, A5b'
|
||||
inputs:
|
||||
|
@ -88,5 +88,6 @@ 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);
|
||||
|
@ -57,17 +57,17 @@ def DisplayStartOfAlgorithm(name: str, *_: Any, **inputs: Any):
|
||||
logPlain('Ausführung vom Algorithmus: \033[92;1m{}\033[0m'.format(name));
|
||||
logPlain('INPUTS');
|
||||
for varname, value in inputs.items():
|
||||
logPlain(' - {} = {}'.format(varname, RepresentValue(value)))
|
||||
logPlain(' - {} = {}'.format(varname, RepresentValue(value)))
|
||||
return;
|
||||
|
||||
def DisplayEndOfAlgorithm(*_: Any, **outputs: Any):
|
||||
logPlain('OUTPUTS:')
|
||||
for varname, value in outputs.items():
|
||||
logPlain(' - {} = {}'.format(varname, RepresentValue(value)))
|
||||
logPlain(' - {} = {}'.format(varname, RepresentValue(value)))
|
||||
return;
|
||||
|
||||
def DisplayMetrics():
|
||||
logPlain('Dauer der Ausführung: t = \033[1m{}\033[0m'.format(TimeElapsed()));
|
||||
logPlain('Dauer der Ausführung: t = \033[1m{}\033[0m'.format(TimeElapsed()));
|
||||
logPlain('Anzahl der Schritte: T(n) = \033[1m{}\033[0m'.format(NumberOfSteps()));
|
||||
return;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user