Infonononononononono
This commit is contained in:
parent
1c7f6684dc
commit
9f5acc3f58
12
4. Theorie/Quicksort.md
Normal file
12
4. Theorie/Quicksort.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Quicksort
|
||||||
|
- Pivoelement muss zuerst bestimmt werden, idealerweise der Median (Median: nicht ohne Sortierung bestimmbar)
|
||||||
|
- Prinzip: Teile und herrsche
|
||||||
|
## Beipiel:
|
||||||
|
253 401 24 590 281
|
||||||
|
253 24 281 401 590
|
||||||
|
\\\\
|
||||||
|
- Elemente werden mit Pivoelement verglichen und avor oder dahinter einsortiert
|
||||||
|
- Vorgang wird wiederholt, bis nur einelemntigre Teilmengen über sind (Rekursion)
|
||||||
|
## Übung:
|
||||||
|
58 12 3 7 62
|
||||||
|
3 7 12 58 62
|
Binary file not shown.
26
Tools/median-getter/main.py
Normal file
26
Tools/median-getter/main.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
from array import array
|
||||||
|
import numbers
|
||||||
|
import statistics
|
||||||
|
array=[]
|
||||||
|
|
||||||
|
def add_items_to_array():
|
||||||
|
print("Operations:\n1.Add numbers\n2.That are all numbers\n3.Exit\nThere are %s Elements in the array" %(len(array)))
|
||||||
|
operation=int(input("Operation:"))
|
||||||
|
if operation == 1:
|
||||||
|
numbers_to_add=float(input("Number:"))
|
||||||
|
array.append(numbers_to_add)
|
||||||
|
add_items_to_array()
|
||||||
|
elif operation == 2:
|
||||||
|
get_median()
|
||||||
|
elif operation == 3:
|
||||||
|
exit()
|
||||||
|
else:
|
||||||
|
print("Input the right operation")
|
||||||
|
add_items_to_array()
|
||||||
|
|
||||||
|
def get_median():
|
||||||
|
median_item=statistics.median(array)
|
||||||
|
print(median_item)
|
||||||
|
exit()
|
||||||
|
|
||||||
|
add_items_to_array()
|
Loading…
x
Reference in New Issue
Block a user