Compare commits
13 Commits
0f1b426f94
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14f59eeb63 | ||
|
|
a6cce9626c | ||
|
|
8d726bf344 | ||
|
|
04eecdb444 | ||
|
|
60c47c20c5 | ||
|
|
89499f524f | ||
|
|
e55d8708a7 | ||
|
|
ea7dfc5bef | ||
|
|
18ece75b67 | ||
|
|
6541a5246d | ||
|
|
3505401c7f | ||
|
|
b193d1d61e | ||
|
|
ae459547c2 |
@@ -68,7 +68,10 @@ var optionsConfigFile = argparse.Options{
|
||||
// Parst cli flags.
|
||||
func ParseCli(args []string) (*types.CliArguments, error) {
|
||||
var err error
|
||||
Parser = argparse.NewParser("cli parser", "Liest Optionen + Flags von Kommandozeile.")
|
||||
Parser = argparse.NewParser(
|
||||
"cli parser",
|
||||
"\033[93;2mEin Programm zur Ausführung verschiedener Algorithmen aus dem Kurs AlgoDat I.\033[0m",
|
||||
)
|
||||
arguments := types.CliArguments{
|
||||
ModeHelp: Parser.NewCommand("help", "Hilfsanleitung anzeigen"),
|
||||
ModeVersion: Parser.NewCommand("version", "Version anzeigen."),
|
||||
|
||||
@@ -38,7 +38,7 @@ func ReadAsset(key string) string {
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- *
|
||||
* METHODS templates
|
||||
* METHODS assets
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
func Help() string {
|
||||
|
||||
@@ -38,9 +38,11 @@ var (
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
var arguments *types.CliArguments
|
||||
var (
|
||||
err1 error
|
||||
err2 error
|
||||
err3 error
|
||||
cmdMissing bool
|
||||
showChecks bool
|
||||
)
|
||||
@@ -50,12 +52,12 @@ func main() {
|
||||
setup.Assets = assets
|
||||
|
||||
// cli arguments parsen
|
||||
arguments, err = cli.ParseCli(os.Args)
|
||||
cmdMissing = cli.ParseCliCommandMissing(err)
|
||||
arguments, err1 = cli.ParseCli(os.Args)
|
||||
cmdMissing = cli.ParseCliCommandMissing(err1)
|
||||
|
||||
// initialisiere basic optionen wie Logging
|
||||
// Programmeinstellungen initialisieren
|
||||
showChecks = false
|
||||
if err == nil {
|
||||
if err1 == nil {
|
||||
if !(arguments.ModeRun.Happened() && arguments.InteractiveMode()) {
|
||||
logging.SetQuietMode(arguments.QuietModeOn())
|
||||
logging.SetDebugMode(arguments.DebugModeOn())
|
||||
@@ -63,34 +65,39 @@ func main() {
|
||||
logging.SetAnsiMode(arguments.ShowColour())
|
||||
showChecks = arguments.ShowChecks()
|
||||
}
|
||||
|
||||
// app config (intern) intialisieren
|
||||
err = setup.AppConfigInitialise()
|
||||
err2 = setup.AppConfigInitialise()
|
||||
setup.SetAppConfigPerformChecks(showChecks)
|
||||
|
||||
if err == nil {
|
||||
if arguments.ModeVersion.Happened() {
|
||||
endpoints_print.Version()
|
||||
return
|
||||
} else if arguments.ModeRun.Happened() {
|
||||
if arguments.InteractiveMode() {
|
||||
endpoints_run.RunInteractive()
|
||||
} else {
|
||||
err = endpoints_run.RunNonInteractive(arguments.GetConfigFile())
|
||||
if err != nil {
|
||||
logging.Fatal(err)
|
||||
}
|
||||
}
|
||||
return
|
||||
} else if arguments.ModeHelp.Happened() {
|
||||
endpoints_print.Help()
|
||||
return
|
||||
} else {
|
||||
endpoints_run.RunInteractive()
|
||||
}
|
||||
} else if cmdMissing {
|
||||
// Fehler melden (fatal)
|
||||
if err1 != nil && !cmdMissing {
|
||||
logging.Fatal(err1)
|
||||
}
|
||||
if err2 != nil {
|
||||
logging.Fatal(err2)
|
||||
}
|
||||
// Wenn der Artefakt ohne Argument aufgerufen wird, keinen Fehler melden, sondern im it-Modus ausführen
|
||||
if cmdMissing {
|
||||
endpoints_run.RunInteractive()
|
||||
return
|
||||
}
|
||||
// Sonst Commands behandeln
|
||||
if arguments.ModeHelp.Happened() {
|
||||
endpoints_print.Help()
|
||||
return
|
||||
} else if arguments.ModeVersion.Happened() {
|
||||
endpoints_print.Version()
|
||||
return
|
||||
} else if arguments.ModeRun.Happened() {
|
||||
if arguments.InteractiveMode() {
|
||||
endpoints_run.RunInteractive()
|
||||
} else {
|
||||
err3 = endpoints_run.RunNonInteractive(arguments.GetConfigFile())
|
||||
if err3 != nil {
|
||||
logging.Fatal(err3)
|
||||
}
|
||||
}
|
||||
return
|
||||
} else {
|
||||
logging.Fatal(err)
|
||||
endpoints_run.RunInteractive()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,19 +14,19 @@ import (
|
||||
* GLOBAL VARIABLES/CONSTANTS
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
var _output_list [][2]int
|
||||
//
|
||||
|
||||
/* ---------------------------------------------------------------- *
|
||||
* ALGORITHM next greater element
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
Inputs: L = Liste von Zahlen, x = Zahl.
|
||||
Inputs: L = Liste von Zahlen.
|
||||
|
||||
Outputs: Liste von Paaren von Elementen und ihrem nächsten größeren Element
|
||||
*/
|
||||
func NextGreaterElement(L []int) [][2]int {
|
||||
clearOutput()
|
||||
output := [][2]int{}
|
||||
|
||||
S := stacks.CREATE()
|
||||
S.INIT()
|
||||
@@ -41,9 +41,9 @@ func NextGreaterElement(L []int) [][2]int {
|
||||
for !S.EMPTY() { // ACHTUNG: schreibe 'while' im Pseudocode, denn dies ist eine while-Schleife in golang
|
||||
element := S.TOP()
|
||||
if element < nextElement {
|
||||
logging.Debug("Stack S | %v; top Element > nextElement; ==> pop und Paar zum Output hinzufügen", S)
|
||||
// falls top Element < next Element, zum Output hinzufügen und vom Stack
|
||||
addToOutput(element, nextElement)
|
||||
// falls top Element < next Element, zum Output hinzufügen und vom Stack entfernen
|
||||
logging.Debug("Stack S | %v; top Element < nextElement; ==> pop und Paar zum Output hinzufügen", S)
|
||||
output = append(output, [2]int{element, nextElement})
|
||||
S.POP()
|
||||
metrics.AddMovesCost()
|
||||
logging.Debug("Stack S | %v", S)
|
||||
@@ -70,31 +70,12 @@ func NextGreaterElement(L []int) [][2]int {
|
||||
for !S.EMPTY() { // ACHTUNG: schreibe 'while' im Pseudocode, denn dies ist eine while-Schleife in golang
|
||||
logging.Debug("Stack S | %v", S)
|
||||
element := S.TOP()
|
||||
output = append(output, [2]int{element, -1})
|
||||
S.POP()
|
||||
metrics.AddMovesCost()
|
||||
addToOutput(element, -1)
|
||||
}
|
||||
|
||||
logging.Debug("Stack S | %v", S)
|
||||
|
||||
return output()
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- *
|
||||
* AUXILIARY METHODS
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
func clearOutput() {
|
||||
_output_list = [][2]int{}
|
||||
}
|
||||
|
||||
func addToOutput(m int, n int) {
|
||||
_output_list = append(_output_list, [2]int{m, n})
|
||||
}
|
||||
|
||||
func output() [][2]int {
|
||||
var output = make([][2]int, len(_output_list))
|
||||
copy(output, _output_list)
|
||||
clearOutput()
|
||||
return output
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ type QueueInt struct {
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- *
|
||||
* METHODS stacks
|
||||
* METHODS queues
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
func CREATE() QueueInt {
|
||||
|
||||
@@ -17,6 +17,7 @@ import sys;
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.abspath(__file__), '..')));
|
||||
|
||||
from src.setup.cli import *;
|
||||
from src.endpoints.exports import *;
|
||||
from src.main import enter;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -24,10 +25,18 @@ from src.main import enter;
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.tracebacklimit = 0;
|
||||
sys.tracebacklimit = 0;
|
||||
try:
|
||||
args = GetArgumentsFromCli(sys.argv[1:]);
|
||||
args = GetArgumentsFromCli(*sys.argv[1:]);
|
||||
except:
|
||||
endpoint_help();
|
||||
exit(1);
|
||||
enter(quiet=args.quiet, debug=args.debug, mode=args.mode[0], path=args.path);
|
||||
enter(
|
||||
mode=args.mode,
|
||||
it=args.it,
|
||||
quiet=args.quiet,
|
||||
debug=args.debug,
|
||||
checks=args.checks,
|
||||
colour=args.colour,
|
||||
config=args.config,
|
||||
);
|
||||
|
||||
@@ -16,7 +16,7 @@ from src.algorithms.methods import *;
|
||||
# GLOBAL VARIABLES/CONSTANTS
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
_output_list: List[Tuple[int,int]]
|
||||
#
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# CHECKS
|
||||
@@ -37,10 +37,10 @@ def postChecks(L: List[int], **_):
|
||||
@algorithmInfos(name='NextGreaterElement (with stacks)', outputnames=['pairs'], preChecks=preChecks, postChecks=postChecks)
|
||||
def NextGreaterElement(L: List[int]) -> List[Tuple[int,int]]:
|
||||
'''
|
||||
Inputs: L = Liste von Zahlen, x = Zahl.
|
||||
Inputs: L = Liste von Zahlen.
|
||||
Outputs: Liste von Paaren von Elementen und ihrem nächsten größeren Element
|
||||
'''
|
||||
clearOutput();
|
||||
output = [];
|
||||
|
||||
S = Stack();
|
||||
S.INIT();
|
||||
@@ -55,10 +55,10 @@ def NextGreaterElement(L: List[int]) -> List[Tuple[int,int]]:
|
||||
logDebug('Stack S | {S}'.format(S=S));
|
||||
while not S.EMPTY():
|
||||
element = S.TOP();
|
||||
# falls element < next Element, zum Output hinzufügen
|
||||
# falls element < next Element, zum Output hinzufügen und vom Stack entfernen
|
||||
if element < nextElement:
|
||||
logDebug('Stack S | {S}; top Element > nextElement; ==> pop und Paar zum Output hinzufügen'.format(S=S))
|
||||
addToOutput(element, nextElement);
|
||||
logDebug('Stack S | {S}; top Element < nextElement; ==> pop und Paar zum Output hinzufügen'.format(S=S))
|
||||
output.append((element, nextElement));
|
||||
S.POP();
|
||||
AddMovesCost();
|
||||
logDebug('Stack S | {S}'.format(S=S));
|
||||
@@ -85,27 +85,7 @@ def NextGreaterElement(L: List[int]) -> List[Tuple[int,int]]:
|
||||
element = S.TOP();
|
||||
S.POP();
|
||||
AddMovesCost();
|
||||
addToOutput(element, -1);
|
||||
output.append((element, -1));
|
||||
|
||||
logDebug('Stack S | {S}'.format(S=S))
|
||||
return output();
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# AUXILIARY METHODS
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
def clearOutput():
|
||||
global _output_list;
|
||||
_output_list = [];
|
||||
return;
|
||||
|
||||
def addToOutput(m: int, n: int):
|
||||
global _output_list;
|
||||
_output_list.append((m, n))
|
||||
return;
|
||||
|
||||
def output() -> List[Tuple[int, int]]:
|
||||
global _output_list;
|
||||
output = _output_list[:] # erstelle Kopie
|
||||
clearOutput()
|
||||
return output
|
||||
return output;
|
||||
|
||||
@@ -6,17 +6,14 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
from src.core.log import *;
|
||||
from src.setup.cli import GetArgumentsFromCli;
|
||||
from src.setup.cli import GetArgumentParser;
|
||||
from src.setup import assets;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# ENDPOINT version
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
def version():
|
||||
with open('assets/VERSION', 'r') as fp:
|
||||
version = ('\n'.join(fp.readlines())).strip();
|
||||
logPlain(version);
|
||||
logPlain(assets.Version());
|
||||
return;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -24,6 +21,5 @@ def version():
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
def help():
|
||||
parser = GetArgumentParser();
|
||||
parser.print_help();
|
||||
logPlain(assets.Help());
|
||||
return;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
from src.core.log import *;
|
||||
from src.core.config import *;
|
||||
from src.setup.display import *;
|
||||
from src.setup import assets;
|
||||
from src.algorithms.exports import *;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -18,6 +19,7 @@ def runInteractive():
|
||||
'''
|
||||
Startet Programm im interaktiven Modus (Konsole).
|
||||
'''
|
||||
logPlain(assets.Logo());
|
||||
logWarn('Interaktiver Modus noch nicht implementiert.');
|
||||
return;
|
||||
|
||||
@@ -31,6 +33,7 @@ def runNonInteractive(path: str):
|
||||
'''
|
||||
config = ReadConfigFile(path);
|
||||
cases = GetAttribute(config, 'parts', 'cases', expectedtype=list, default=[]);
|
||||
logPlain(assets.Logo());
|
||||
for caseindex, case in enumerate(cases):
|
||||
command = GetAttribute(case, 'command', expectedtype=str, default='');
|
||||
descr = GetAttribute(case, 'description', expectedtype=str, default='');
|
||||
|
||||
@@ -13,8 +13,6 @@ sys.path.insert(0, _path_to_python_project);
|
||||
os.chdir(_path_to_python_project);
|
||||
|
||||
from src.core.log import *;
|
||||
from src.core.utils import IsTrue;
|
||||
from src.core.utils import IsFalse;
|
||||
from src.setup.cli import *;
|
||||
from src.setup import appconfig;
|
||||
from src.endpoints.exports import *;
|
||||
@@ -30,14 +28,16 @@ PATH_TO_CONFIG: str = '../config.yml';
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
def enter(
|
||||
mode: str,
|
||||
mode: Union[str, None],
|
||||
it: bool,
|
||||
quiet: bool,
|
||||
debug: bool,
|
||||
checks: bool,
|
||||
colour: bool,
|
||||
config: Any, **_
|
||||
config: Union[str, None],
|
||||
**_
|
||||
):
|
||||
# Programmeinstellungen initialisieren
|
||||
if not (mode == 'run' and it):
|
||||
SetQuietMode(quiet);
|
||||
SetDebugMode(debug);
|
||||
@@ -46,7 +46,15 @@ def enter(
|
||||
|
||||
config = config if isinstance(config, str) else PATH_TO_CONFIG;
|
||||
|
||||
if mode == 'version':
|
||||
# Wenn der Artefakt ohne Argument aufgerufen wird, keinen Fehler melden, sondern im it-Modus ausführen
|
||||
if mode is None:
|
||||
endpoint_runInteractive();
|
||||
return;
|
||||
# Sonst Commands behandeln
|
||||
if mode == 'help':
|
||||
endpoint_help();
|
||||
return;
|
||||
elif mode == 'version':
|
||||
endpoint_version();
|
||||
return;
|
||||
elif mode == 'run':
|
||||
@@ -54,8 +62,9 @@ def enter(
|
||||
endpoint_runInteractive();
|
||||
else:
|
||||
endpoint_runNonInteractive(path=config);
|
||||
else: # elif mode
|
||||
endpoint_help();
|
||||
return;
|
||||
else:
|
||||
endpoint_runInteractive();
|
||||
return;
|
||||
return;
|
||||
|
||||
@@ -71,11 +80,11 @@ if __name__ == '__main__':
|
||||
endpoint_help();
|
||||
exit(1);
|
||||
enter(
|
||||
mode=args.mode[0],
|
||||
mode=args.mode,
|
||||
it=args.it,
|
||||
quiet=args.quiet,
|
||||
debug=args.debug,
|
||||
checks=IsTrue(args.checks[0]),
|
||||
colour=IsTrue(args.colour[0]),
|
||||
checks=args.checks,
|
||||
colour=args.colour,
|
||||
config=args.config,
|
||||
);
|
||||
|
||||
38
code/python/src/setup/assets.py
Normal file
38
code/python/src/setup/assets.py
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# IMPORTS
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
from src.local.io import *;
|
||||
|
||||
from src.core.utils import DedentIgnoreFirstLast
|
||||
from src.setup.cli import GetArgumentParser;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# METHODS assets
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
def Help() -> str:
|
||||
parser = GetArgumentParser();
|
||||
with io.StringIO() as fp:
|
||||
parser.print_help(fp)
|
||||
text = fp.getvalue();
|
||||
return text;
|
||||
|
||||
def Logo() -> str:
|
||||
## NOTE: expandiert ansi nicht:
|
||||
# with open('assets/LOGO', 'r') as fp:
|
||||
# logo = (''.join(fp.readlines())).strip();
|
||||
logo = DedentIgnoreFirstLast('''
|
||||
+--------------------+
|
||||
| \033[32;1mAlgoDat I\033[0m |
|
||||
+--------------------+
|
||||
''') + '\n';
|
||||
return logo;
|
||||
|
||||
def Version() -> str:
|
||||
with open('assets/VERSION', 'r') as fp:
|
||||
version = (''.join(fp.readlines())).strip();
|
||||
return version;
|
||||
@@ -10,6 +10,8 @@ from src.local.typing import *;
|
||||
|
||||
from src.core.log import *;
|
||||
from src.core.utils import DedentIgnoreFirstLast;
|
||||
from src.core.utils import IsTrue;
|
||||
from src.core.utils import IsFalse;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# GLOBAL VARIABLES
|
||||
@@ -28,12 +30,12 @@ def GetArgumentParser() -> argparse.ArgumentParser:
|
||||
prog='code/main.py',
|
||||
description=DedentIgnoreFirstLast('''
|
||||
\033[93;1mBeschreibung:\033[0m
|
||||
\033[93;2mEin Programm, das verschiedene Algorithmen aus dem Kurs AlgoDat I testet.\033[0m
|
||||
\033[93;2mEin Programm zur Ausführung verschiedener Algorithmen aus dem Kurs AlgoDat I.\033[0m
|
||||
'''),
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
);
|
||||
parser.add_argument('mode',
|
||||
nargs=1,
|
||||
nargs='?',
|
||||
choices=['version', 'help', 'run'],
|
||||
help=DedentIgnoreFirstLast('''
|
||||
help = Hilfsanleitung anzeigen.
|
||||
@@ -51,9 +53,12 @@ def GetArgumentParser() -> argparse.ArgumentParser:
|
||||
'''),
|
||||
),
|
||||
parser.add_argument('--colour', nargs=1, type=str, default=['False'], help='(bool) Ob Logging färblich angezeigt wird.')
|
||||
parser.add_argument('--config', nargs=1, type=str, help='(string) Pfad zur Configdatei (nur für run Endpunkt).');
|
||||
parser.add_argument('--config', nargs=1, type=str, help='(string) Pfad zur Configdatei (nur für run Endpunkt).');
|
||||
return parser;
|
||||
|
||||
def GetArgumentsFromCli(*cli_args: str) -> argparse.Namespace:
|
||||
parser = GetArgumentParser();
|
||||
return parser.parse_args(cli_args);
|
||||
args = parser.parse_args(cli_args);
|
||||
args.checks=IsTrue(args.checks[0]);
|
||||
args.colour=IsTrue(args.colour[0]);
|
||||
return args;
|
||||
|
||||
@@ -6,11 +6,11 @@ Inhaltsverzeichnis
|
||||
- [Vorlesungswoche 2](./woche2.md)
|
||||
- [Vorlesungswoche 3](./woche3.md)
|
||||
- [Vorlesungswoche 4](./woche4.md)
|
||||
- [Vorlesungswoche 5](./woche4.md)
|
||||
- [Vorlesungswoche 6](./woche4.md)
|
||||
- [Vorlesungswoche 7](./woche4.md)
|
||||
- [Vorlesungswoche 8](./woche4.md)
|
||||
- [Vorlesungswoche 9](./woche4.md)
|
||||
- [Vorlesungswoche 5](./woche5.md)
|
||||
- [Vorlesungswoche 6](./woche6.md)
|
||||
- [Vorlesungswoche 7](./woche7.md)
|
||||
- [Vorlesungswoche 8](./woche8.md)
|
||||
- [Vorlesungswoche 9](./woche9.md)
|
||||
- [Vorlesungswoche 10](./woche10.md)
|
||||
- [Vorlesungswoche 11](./woche11.md)
|
||||
- [Vorlesungswoche 12](./woche12.md)
|
||||
|
||||
@@ -2,13 +2,26 @@
|
||||
|
||||
## Agenda ##
|
||||
|
||||
- [ ]
|
||||
- [ ]
|
||||
- Gruppe 1:
|
||||
- Verkettete Listen
|
||||
- basic methods/attributes
|
||||
- Stacks + Queues
|
||||
- LIFO=FILO vs. FIFO=LILO
|
||||
- PseudoCode-Algorithmus für NextGreaterElement mittels Stacks erarbeitet und diskutiert
|
||||
- ACHTUNG: im code-Ordner ([go-Variante](../code/golang/pkg/algorithms/stacks/next_greater_element/next_greater_element.go) und [python-Variante](../code/python/src/algorithms/stacks/next_greater_element.py)) habe ich einen vereinfachten Algorithmus implementiert.
|
||||
- Gruppe 2:
|
||||
- PseudoCode-Algorithmus für NextGreaterElement mittels Stacks erarbeitet und diskutiert
|
||||
- ACHTUNG: im code-Ordner ([go-Variante](../code/golang/pkg/algorithms/stacks/next_greater_element/next_greater_element.go) und [python-Variante](../code/python/src/algorithms/stacks/next_greater_element.py)) habe ich einen vereinfachten Algorithmus implementiert.
|
||||
- Grundkonzepte für gerichtete/ungerichtete Graphen und Bäume besprochen
|
||||
|
||||
## Nächste Woche ##
|
||||
|
||||
-
|
||||
- Sortierungsalgorithmen
|
||||
- Bäume
|
||||
|
||||
### TODOs (Studierende) ###
|
||||
|
||||
-
|
||||
- VL-Inhalte aus Wochen 3 + 4 durchgehen
|
||||
- jeden Sortierungsalgorithmus und MaxHeap verstehen
|
||||
- Darstellung von Daten als Bäume verstehen
|
||||
- freiwillige ÜB 4 + Pflichtserie 2
|
||||
|
||||
@@ -2,13 +2,41 @@
|
||||
|
||||
## Agenda ##
|
||||
|
||||
- [ ]
|
||||
- [ ]
|
||||
- Gruppe 1
|
||||
- [x] Alle Sortierverfahren durchgegangen; argumentierte, wieso die Algorithmen korrekt sind.
|
||||
- [x] Bäume und Listendarstellung von **fast vollständige binäre Bäume**.
|
||||
- [x] Max-Heap-Eigenschaft (MHE).
|
||||
- [x] Theorem: folgende Aussagen sind äquivalent
|
||||
- T hat MHE
|
||||
- (Definition) alle Unterbäume von T haben Max in Wurzel, d. h.
|
||||
für alle Knoten, e, gilt
|
||||
```
|
||||
value(e) ≥ max{value(e') | e' Unterhalb von e in T}
|
||||
```
|
||||
- für alle Knoten, e, gilt
|
||||
```
|
||||
value(e) ≥ max{value(e') | e' Tochterknoten von e in T}
|
||||
```
|
||||
- L[i] = L[2i+1] und L[i] = L[2i+2] (jeweils solange Indexes in Listendarstellung L, wobei L = Listendarstellung von Baum T).
|
||||
- Gruppe 2
|
||||
- [x] Alle Sortierverfahren durchgegangen; argumentierte, wieso die Algorithmen korrekt sind.
|
||||
(Etwas ausführlicher, weil MHE, usw. schon in der Übung diskutiert wurden.)
|
||||
|
||||
**Anmerkung.**
|
||||
Bei Quicksort konnten wir sehen, dass die Zeit- (und Satzbewegungs!) komplexität durch
|
||||
$C(n) = 2C(n/2) + Θ(n)$ gegeben ist (warum diese Koeffizienten, warum Θ(n)?).
|
||||
</br>
|
||||
Laut **Mastertheorem** gilt also $C(n) ∈ Θ(n·log(n))$ (warum?).
|
||||
</br>
|
||||
Das ist aber der Worst-case.
|
||||
</br>
|
||||
Wie verhält sich das beim Average-Case ($C_{av}(n)$)?
|
||||
|
||||
## Nächste Woche ##
|
||||
|
||||
-
|
||||
- Ab VL5 + Blatt 6.
|
||||
|
||||
### TODOs (Studierende) ###
|
||||
|
||||
-
|
||||
- VL-Inhalte aus Wochen 4 + 5 durchgehen
|
||||
- freiwillige ÜB 5 + Pflichtserie 3.
|
||||
|
||||
@@ -2,13 +2,10 @@
|
||||
|
||||
## Agenda ##
|
||||
|
||||
- [ ]
|
||||
- [ ]
|
||||
|
||||
## Nächste Woche ##
|
||||
|
||||
-
|
||||
- [x] Mergesort, inkl. Pseudo-Code
|
||||
- [x] natürliches Mergesort, inkl. Aspekte
|
||||
- [x] k-Wege Mergesort
|
||||
|
||||
### TODOs (Studierende) ###
|
||||
|
||||
-
|
||||
- weiter an Pflichtserie3 arbeiten.
|
||||
|
||||
@@ -2,13 +2,19 @@
|
||||
|
||||
## Agenda ##
|
||||
|
||||
- [ ]
|
||||
- [ ]
|
||||
- [x] Orga: nochmalige Abstimmung der Studierenden über Präsenz v. Digital
|
||||
---> überwiegende Mehrheit für weiteren Präsenzbetrieb.
|
||||
|
||||
## Nächste Woche ##
|
||||
Aspekte und Berechnungen mit binären Suchbäumen
|
||||
|
||||
-
|
||||
- Aspekte, insbesondere *ausgeglichen*.
|
||||
- Motivation: wieso wollen wir *ausgeglichene* Suchbäume?
|
||||
- Optimierung der Tiefe h vis-á-vis Anzahl der Knoten, n.
|
||||
- Suchalgorithmus im Suchbaum
|
||||
- welche Verhältnisse müssen zw. den Knoten gelten?
|
||||
- Ansatz bei INSERT und ROTATE, um *ausgeglichenen* Baum
|
||||
mit passenden Verhältnissen zw. Knoten zu erzeugen.
|
||||
|
||||
### TODOs (Studierende) ###
|
||||
|
||||
-
|
||||
- weiter an Pflichtserie3 arbeiten und vor der Frist abgeben.
|
||||
|
||||
Reference in New Issue
Block a user