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'); |         logDebug('x in Position m gefunden'); | ||||||
|         return m; |         return m; | ||||||
|     elif x < L[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); |         index = BinarySearch(L=L[:m], x=x); | ||||||
|         return index; |         return index; | ||||||
|     else: # x > L[m] |     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); |         index = BinarySearch(L=L[m+1:], x=x); | ||||||
|         if index >= 0: |         if index >= 0: | ||||||
|             index += (m + 1); # NOTE: muss Indexwert kompensieren |             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!') |         logDebug('Element kann sich nicht in der Liste befinden!') | ||||||
|         return -1; |         return -1; | ||||||
|     p = getSuchposition(L=L, x=x, u=u, v=v); |     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: |     if L[p] == x: | ||||||
|         logDebug('x in Position p gefunden'); |         logDebug('x in Position p gefunden'); | ||||||
|         return p; |         return p; | ||||||
|     elif x > L[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); |         return InterpolationSearch(L=L, x=x, u=p+1, v=v); | ||||||
|     else: # x < L[p] |     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); |         return InterpolationSearch(L=L, x=x, u=u, v=p-1); | ||||||
| 
 | 
 | ||||||
| def getSuchposition(L: List[int], x: int, u: int, v: int) -> int: | def getSuchposition(L: List[int], x: int, u: int, v: int) -> int: | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user