This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:discrete:fall2021:projects:saf1 [2021/10/06 23:37] – Fixed page formatting smalik3 | notes:discrete:fall2021:projects:saf1 [2021/10/07 03:13] (current) – [Display] ccolocci | ||
---|---|---|---|
Line 28: | Line 28: | ||
====Process==== | ====Process==== | ||
+ | |||
+ | ==Randomness in Lua== | ||
+ | |||
+ | As with the projects before, `math.random()` can be used to generate random values for the array. It may also have a different purpose depending on how you approach this project. While there are many ways to show the algorithms... rinse and repeat, or do a brand new array... one can use `math.random()` to randomize which algorithm is used to sort the array upon each new initialized array. | ||
==Bubble Sort== | ==Bubble Sort== | ||
Line 58: | Line 62: | ||
{2 3 5 7 9} -> {2 3 5 7 9} | {2 3 5 7 9} -> {2 3 5 7 9} | ||
</ | </ | ||
- | You will notice that, in this specific example, the algorithm had to sweep through 5 times in order to reach the final result. You will also notice that the complete sorting was finished after pass 4, but the algorithm did a 5th one as well. This is because the algorithm has to do one whole pass without doing a swap in order for it to be considered a successful sort. | + | You will notice that, in this specific example, the algorithm had to sweep through 5 times in order to reach the final result. You will also notice that the complete sorting was finished after pass 4, but the algorithm did a 5th one as well. This is because the algorithm has to do one whole pass without doing a swap in order for it to be considered a successful sort. You will soon read about an algorithm (next algorithm) that is very similar, except far more robust and faster. |
==Selection Sort== | ==Selection Sort== | ||
Line 105: | Line 109: | ||
====Display==== | ====Display==== | ||
+ | |||
+ | In order to meet project specifications, | ||
==A Note on the Print Function== | ==A Note on the Print Function== | ||
print() is a very versatile tool; there are so many things to play around with and so many different arguments to take advantage of. For example, these are the arguments for print(): text [x=0 y=0] [color=12] [fixed=false] [scale=1] [smallfont=false]. The first three are pretty self-explanatory, | print() is a very versatile tool; there are so many things to play around with and so many different arguments to take advantage of. For example, these are the arguments for print(): text [x=0 y=0] [color=12] [fixed=false] [scale=1] [smallfont=false]. The first three are pretty self-explanatory, | ||
+ | |||
+ | Alternatively, | ||
=====References===== | =====References===== | ||
https:// | https:// | ||
+ | |||
+ | https:// | ||
https:// | https:// | ||
Line 118: | Line 128: | ||
https:// | https:// | ||
+ | https:// | ||
=====Submission===== | =====Submission===== | ||