diff --git a/code/golang/internal/algorithms/search/interpol/interpol.go b/code/golang/internal/algorithms/search/interpol/interpol.go index d871f02..bb7af50 100644 --- a/code/golang/internal/algorithms/search/interpol/interpol.go +++ b/code/golang/internal/algorithms/search/interpol/interpol.go @@ -38,15 +38,14 @@ func InterpolationSearch(L []int, x int, u int, v int) int { } metrics.AddTimeCost() p := getSuchposition(L, x, u, v) - logging.Debug("Interpolante von x in (u, v)=(%[1]v, %[2]v) ist p = %[3]v.", u, v, p) if L[p] == x { - logging.Debug("x in Position p gefunden") + logging.Debug("Interpolante in (%[1]v, %[2]v) ist p = %[3]v; L[p] == x; ===> Element gefunden", u, v, p) return p } else if x < L[p] { - logging.Debug("Suche in linker Hälfte fortsetzen.") + logging.Debug("Interpolante in (%[1]v, %[2]v) ist p = %[3]v; L[p] > x; ===> suche in linker Hälfte", u, v, p) return InterpolationSearch(L, x, u, p-1) } else { // } else if x > L[p] { - logging.Debug("Suche in rechter Hälfte fortsetzen.") + logging.Debug("Interpolante in (%[1]v, %[2]v) ist p = %[3]v; L[p] < x; ===> suche in rechter Hälfte", u, v, p) return InterpolationSearch(L, x, p+1, v) } } diff --git a/code/golang/internal/setup/setup_display.go b/code/golang/internal/setup/setup_display.go index 18ca5a5..fb370e6 100644 --- a/code/golang/internal/setup/setup_display.go +++ b/code/golang/internal/setup/setup_display.go @@ -103,8 +103,8 @@ func DisplayEndOfAlgorithm(outputs map[string]interface{}) { func DisplayMetrics() { // logging.Plain("Dauer der Ausführung: t = \033[1m%[1]v\033[0m", metrics.GetTimeElapsed()) logging.Plain("Dauer der Ausführung: t = \033[1m%[1]v\033[0m", metrics.GetTimeElapsedLongFormat()) - logging.Plain("Kosten (Zeit): T(n) = \033[1m%[1]v\033[0m", metrics.GetTimeCost()) - logging.Plain("Kosten (Platz): S(n) = \033[1m%[1]v\033[0m", metrics.GetSpaceCost()) + logging.Plain("Kosten (Zeit): T(n) = \033[1m%[1]v\033[0m", displayCost(metrics.GetTimeCost())) + logging.Plain("Kosten (Platz): S(n) = \033[1m%[1]v\033[0m", displayCost(metrics.GetSpaceCost())) return } @@ -120,3 +120,10 @@ func DisplayBar(options ...int) { logging.Plain("+%[1]s+", strings.Repeat("-", n)) return } + +func displayCost(cost int) string { + if cost > 0 { + return fmt.Sprintf("%v", cost) + } + return "-" +}