master > master: code - minor (logging)
This commit is contained in:
parent
dac99c0fa0
commit
e9dad73a05
@ -55,11 +55,11 @@ def BinarySearch(L: List[int], x: int) -> int:
|
||||
logDebug('x in Position m gefunden');
|
||||
return m;
|
||||
elif x < L[m]:
|
||||
logDebug('Suche in L[0], L[1], ..., L[m-1] fortsetzen, m = {}.'.format(m));
|
||||
logDebug('Suche in linker Hälfte fortsetzen.');
|
||||
index = BinarySearch(L=L[:m], x=x);
|
||||
return index;
|
||||
else: # x > L[m]
|
||||
logDebug('Suche in L[m+1], L[m+2], ..., L[len(L)-1] fortsetzen, m = {}.'.format(m));
|
||||
logDebug('Suche in rechter Hälfte fortsetzen.');
|
||||
index = BinarySearch(L=L[m+1:], x=x);
|
||||
if index >= 0:
|
||||
index += (m + 1); # NOTE: muss Indexwert kompensieren
|
||||
|
@ -50,15 +50,15 @@ def InterpolationSearch(L: List[int], x: int, u: int, v: int) -> int:
|
||||
logDebug('Element kann sich nicht in der Liste befinden!')
|
||||
return -1;
|
||||
p = getSuchposition(L=L, x=x, u=u, v=v);
|
||||
logDebug('Interpolant von x in (u, v)={uv} ist p = {p}.'.format(uv=(u, v), p=p));
|
||||
logDebug('Interpolante von x in (u, v)={uv} ist p = {p}.'.format(uv=(u, v), p=p));
|
||||
if L[p] == x:
|
||||
logDebug('x in Position p gefunden');
|
||||
return p;
|
||||
elif x > L[p]:
|
||||
logDebug('Suche in L[p+1], L[p+2], ..., L[v] fortsetzen.');
|
||||
logDebug('Suche in rechter Hälfte fortsetzen.');
|
||||
return InterpolationSearch(L=L, x=x, u=p+1, v=v);
|
||||
else: # x < L[p]
|
||||
logDebug('Suche in L[u], L[u+1], ..., L[p-1] fortsetzen.');
|
||||
logDebug('Suche in linker Hälfte fortsetzen.');
|
||||
return InterpolationSearch(L=L, x=x, u=u, v=p-1);
|
||||
|
||||
def getSuchposition(L: List[int], x: int, u: int, v: int) -> int:
|
||||
|
Loading…
x
Reference in New Issue
Block a user