It is only the index values that are important and that reflect the mechanics of the sort. After the sort, a 0. The grains are placed side by side to create one long sound wave that demonstrates the algorithm. Once again, the actual values being sorted are irrelevant. It is only the index values that are important and that reflect the mechanics of the quick sort.
As before, after the sort, a 0. Join the ZME newsletter for amazing science news, features, and exclusive scoops. More than 40, subscribers can't be wrong. You can download the software program here and then make your own sounds and videos.
Tibi is a science journalist and co-founder of ZME Science. He writes mainly about emerging tech, physics, climate, and space. In his spare time, Tibi likes to make weird music on his computer and groom felines. The Sound of Sorting demo program is very intuitive to use. It contains many sorting algorithms, which are selectable via the list box on the right. For the quick sort variants the pivot rule can be selected separately. When pressing "Run", the algorithm is started on selected input. With "Reset" a running algorithm is stopped, and a new random input is created.
When "Sound" is activated, the program will generate sound effects on the default audio output. The "Speed" slider changes the algorithms execution speed by adding a delay for each array access. Due to the 1ms resolution of timers on Windows, the speed scale is smaller.
The algorithm's visualization contains mostly white bars representing the value of the array position corresponding to the x-axis. When the algorithm gets or sets an array item, the white bar runs red for one algorithmic step. A swap operation is represented by two bars turning red and their values being exchanged. Some algorithms specially colorize bars which represent indexes, pointers or other information about the internal mechanisms of the algorithm.
Both value comparisons and array accesses are counted and shown in real time. The comparison counter includes ternary comparisons as just one operation. Due to algorithms often using extra memory or local variables, the array access counter highly depends on the actual algorithm implementation. The generated sound effects depend on the values being compared. The length of each comparison's sound effect can be modified using the "Sound Sustain" slider.
The frequency of the sound is calculated from the compared values. The sound wave itself is triangular and modulated with an ADSR envelope. This yields the "8-bit game tune" feeling. An item value is scaled with double precision to the frequency range Hz - 1, Hz, which is large but not too high to be annoying.
0コメント