This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:discrete:fall2021:projects:saf2 [2021/10/16 00:41] – [References] mpronti2 | notes:discrete:fall2021:projects:saf2 [2021/10/21 03:16] (current) – Added direct link to References in Slow Sort algorithm conclusion smalik3 | ||
---|---|---|---|
Line 7: | Line 7: | ||
=====Objective===== | =====Objective===== | ||
+ | |||
Using the TIC-80 fantasy console simulator on your pi, implement a program that performs a sorting of a randomized list of values, both displaying an animation of the sort, along with timing and keeping track of the approximate number of steps needed to accomplish the task for variable numbers of non-animated runtimes. | Using the TIC-80 fantasy console simulator on your pi, implement a program that performs a sorting of a randomized list of values, both displaying an animation of the sort, along with timing and keeping track of the approximate number of steps needed to accomplish the task for variable numbers of non-animated runtimes. | ||
Line 29: | Line 30: | ||
====Process==== | ====Process==== | ||
+ | |||
+ | ===Merge Sort=== | ||
+ | |||
+ | Merge Sort is regarded as one of the most efficient sorting algorithms known. It is an algorithm based on comparison sort logic. The logic goes as follows: | ||
+ | < | ||
+ | -Divide the unsorted list into *n* sub-lists, each containing one element. | ||
+ | -Repeatedly merge sub-lists to produce new sorted sub-lists until only one remains. | ||
+ | </ | ||
+ | In simple terms, the algorithm repeatedly separates the list into sub-lists until each sub-list has only two integers. Then, it compares the two (and therefore sorts the sub-list). It keeps going through this, recursively, | ||
===Cocktail Sort=== | ===Cocktail Sort=== | ||
Line 77: | Line 87: | ||
As can be seen based on the fact that the subarray outsizes the ingoing dataset in the example, as dataset values become larger, this approach becomes infinitely less useful, but is actually very, very fast in smaller, more controlled applications like mine, where the dataset simply contains a no-repeat set of values from 1-datasetSize, | As can be seen based on the fact that the subarray outsizes the ingoing dataset in the example, as dataset values become larger, this approach becomes infinitely less useful, but is actually very, very fast in smaller, more controlled applications like mine, where the dataset simply contains a no-repeat set of values from 1-datasetSize, | ||
+ | |||
+ | ===Gnome Sort=== | ||
+ | |||
+ | Also known as Stupid Sort, this algorithm is very similar in concept to Insert Sort, in the sense that it parses through the list one element at a time. It goes through the list, starting with a position of 0 up until the length of the list, comparing each element to the last. If the current is less than the previous, they are swapped, and the position decreases by one. The algorithm finishes when the position equals that of the length of the list. | ||
+ | |||
+ | ===Slow Sort=== | ||
+ | |||
+ | Similar to Merge Sort and Quick Sort, Slow Sort uses a divide and conquer technique with one catch: it is // | ||
+ | |||
+ | Slow Sort is given three parameters: array, initial index, and ending index. First working by making sure that the initial index is smaller than the ending index, if not the algorithm will not run. Once that is out of the way, the middle index (roughly between initial index and ending index) is calculated and stored. Then the algorithm works recursively so sort from the initial index to middle index, then from one after the middle index to the ending index. | ||
+ | |||
+ | It then does a comparison of values, seeing if the element at the middle index of the array is greater than the element at the ending index of the array. If this condition turns out true then both elements are swapped. After this, we do one last sort... and this one is the kicker. Now we will recursive call our Slow Sort algorithm with the same table, same initial index, and the ending index minus one. | ||
+ | |||
+ | The combination of all these recursive calls and minor swaps is what results in the extremely slow speeds of this algorithm. For more information check out the paper written on this algorithm in [[https:// | ||
+ | |||
====Display==== | ====Display==== | ||
+ | Displaying the output in TIC80 is very simple. There is a print() function in LUA that is used to display output to the screen. With the print function you can provide the exact X and Y coordinates that you would like to display your output. Print also supports providing a numerical character that is associated with a specific color, meaning you can have all different colors of output. You can see the numbers that are associated with specific colors here https:// | ||
+ | With the series of safX projects in mind, it is important to note that we must display our output after every iteration of a sort. So we must show how each number in the list is sorted at a time. If you have a list of ten numbers, you are likely going to want to show at least 10 iterations of the sort. Depending on the algorithm at hand, you may have a different amount of sorts displayed. | ||
=====References===== | =====References===== | ||
https:// | https:// | ||
+ | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | http:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
=====Submission===== | =====Submission===== | ||
+ | |||
+ | To submit the game file, our " | ||
+ | |||
+ | //Of course, if you are using the TIC-80 application on your Pi then the file will exist there when saved.// | ||
+ | |||
+ | To submit this project using the **submit** tool, run the following command at your lab46 prompt: | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | Submitting DESIG project " | ||
+ | -> GAMENAME.tic(OK) | ||
+ | |||
+ | SUCCESSFULLY SUBMITTED | ||
+ | </ | ||
+ | |||
+ | NOTE: " | ||
+ | |||
I'll be looking for the following: | I'll be looking for the following: | ||