master > master: code go - messages verbessert
This commit is contained in:
parent
38025247c7
commit
337790f3cd
@ -38,15 +38,14 @@ func InterpolationSearch(L []int, x int, u int, v int) int {
|
|||||||
}
|
}
|
||||||
metrics.AddTimeCost()
|
metrics.AddTimeCost()
|
||||||
p := getSuchposition(L, x, u, v)
|
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 {
|
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
|
return p
|
||||||
} else if x < L[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)
|
return InterpolationSearch(L, x, u, p-1)
|
||||||
} else { // } else if x > L[p] {
|
} 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)
|
return InterpolationSearch(L, x, p+1, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,8 +103,8 @@ func DisplayEndOfAlgorithm(outputs map[string]interface{}) {
|
|||||||
func DisplayMetrics() {
|
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.GetTimeElapsed())
|
||||||
logging.Plain("Dauer der Ausführung: t = \033[1m%[1]v\033[0m", metrics.GetTimeElapsedLongFormat())
|
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 (Zeit): T(n) = \033[1m%[1]v\033[0m", displayCost(metrics.GetTimeCost()))
|
||||||
logging.Plain("Kosten (Platz): S(n) = \033[1m%[1]v\033[0m", metrics.GetSpaceCost())
|
logging.Plain("Kosten (Platz): S(n) = \033[1m%[1]v\033[0m", displayCost(metrics.GetSpaceCost()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,3 +120,10 @@ func DisplayBar(options ...int) {
|
|||||||
logging.Plain("+%[1]s+", strings.Repeat("-", n))
|
logging.Plain("+%[1]s+", strings.Repeat("-", n))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func displayCost(cost int) string {
|
||||||
|
if cost > 0 {
|
||||||
|
return fmt.Sprintf("%v", cost)
|
||||||
|
}
|
||||||
|
return "-"
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user