summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinternetlandlord <f.fredhenry@gmail.com>2022-10-20 12:06:20 -0500
committerinternetlandlord <f.fredhenry@gmail.com>2022-10-20 12:06:20 -0500
commitcbb3b74f42824a5e178c556c6b7db6810232e441 (patch)
tree1d0a7f4435b9cfc0eab4ac58fa7dd408b03093de
parent27170a41d9cf47a8048bccb040fdb287b8af7bcc (diff)
Housekeeping on scripts and README.md
-rw-r--r--README.md8
-rwxr-xr-xquick-sort.py12
-rwxr-xr-xselection-sort.py11
3 files changed, 14 insertions, 17 deletions
diff --git a/README.md b/README.md
index 98e11ab..239a41f 100644
--- a/README.md
+++ b/README.md
@@ -15,16 +15,16 @@ The functional file contains I/O functions for ingressing and egressing data.
More to come!
-###### inputout.py
+#### inputout.py
* Contains functions that are imported into algorithm scripts for ingressing/
exporting data to csv
-###### list-generator.py
+#### list-generator.py
* Used to create randomly-generated CSVs for testing algorithm performance
-###### selection-sort.py
+#### selection-sort.py
* Basic selection sort algorithm, n\*n=n^2 complexity (very slow)
-###### tripler.py
+#### tripler.py
* Serves as a proof-of-concept for file manipulation
diff --git a/quick-sort.py b/quick-sort.py
index 966d550..e048970 100755
--- a/quick-sort.py
+++ b/quick-sort.py
@@ -1,7 +1,8 @@
#!/bin/python3
-# ---------- title
-
+# ---------- Quick Sort
+# Python implementation of the quick sort algorithm
+# performed against a randomly-generated list of numbers
# ---------- Imported modules
@@ -16,7 +17,7 @@ target = sys.argv[1]
# ingress of data
numdata = io.ingressCSV(target)
-# quick sort algorithm, defined as a function (to be called recursively)
+# quick sort algorithm, defined as a function to enable recursive calling
def quickSort(data):
if(len(data)>1):
pivot = int(len(data)/2)
@@ -35,11 +36,6 @@ def quickSort(data):
# running quicksort against the ingressed data
numdata = quickSort(numdata)
-#FIXME: try using a separate list initialization if problems encountered
-#writedata = quiskSort(numdata)
-#io.egressCSV(writedata,target)
-
-
# finishing up
print("Sort complete, writing to file!")
io.egressCSV(numdata,target)
diff --git a/selection-sort.py b/selection-sort.py
index c41c86e..b500333 100755
--- a/selection-sort.py
+++ b/selection-sort.py
@@ -1,7 +1,8 @@
#!/bin/python3
-# ---------- title
-
+# ---------- Selection Sort
+# Python implementation of the selection sort algorithm
+# n^n complexity, so it will start to chug on larger datasets.
# ---------- Imported modules
@@ -11,9 +12,9 @@ import sys
# ---------- Main
-target = sys.argv[1]
# ingress of data
+target = sys.argv[1]
numdata = io.ingressCSV(target)
# selection sort algorithm
@@ -24,9 +25,9 @@ for i in range(len(numdata)):
if numdata[mindex] > numdata[j]:
mindex = j
- # updating values - trying without simulatenous assignment
+ # updating values using simultaneous assignments
numdata[i], numdata[mindex] = numdata[mindex], numdata[i]
# finishing up
-print("writing to file")
+print("Sort complete, writing to file!")
io.egressCSV(numdata,target)