This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * These two functions do the same thing. | |
| * They check if a second array contains squared values of the first array. | |
| * The first is slow. Every value is compared to each other. | |
| * The second is faster, it runs through each array only once. | |
| * The approach of the second function I refer to as a "frequency counter". | |
| */ | |
| function nestedLoop (array1, array2) { | |
| if (array1.length !== array2.length) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Named 'bubble sort' because the largest value will | |
| * bubble to the array's end after the first pass. | |
| * | |
| * Instructions: | |
| * Beginning at the start of the array and | |
| * progressing to the end, repeatedly swap adjacent | |
| * elements in place if they are in the wrong order. | |
| * To sort the entire array, perform subsequent passes | |
| * going only as far as the previously sorted element. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Selection Sort: The name comes from the process of | |
| * repeatedly selecting the minimum element and swapping it | |
| * with the first unsorted element. Selection sort works | |
| * as well by selecting and sorting maximum values. | |
| * | |
| * Process: Iterate through the array to find the minimum | |
| * value. Swap the minumum value with the first | |
| * element. Repeat this process beginning with the element | |
| * proceeding the previously sorted value. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Insertion Sort: The name comes from the process of | |
| * maintaining a sorted subarray by which unsorted values | |
| * are inserted within through a process of repeated | |
| * swapping. | |
| * | |
| * Process: | |
| * Maintain a sorted subarray in place that begins with | |
| * only the array's first element. Beginning at the second | |
| * element, repeatedly swap the current element with those |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Merge Sort: Gets its name from the process of repeatedly | |
| * splitting the original array and merging it back together. | |
| * | |
| * Process: | |
| * Repeatedly split the original array until all subarrays | |
| * are of just one element. Remerge the subarrays and | |
| * continuously sort the elements. | |
| * | |
| * Performance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Quick Sort: Gets its name from being... Quick...? | |
| * | |
| * Process: | |
| * Pick an element of the array, a value to pivot around. | |
| * Place all less than values before the pivot, and all the | |
| * greater than values after the pivot. These values do not | |
| * need to be sorted, just properly placed before or | |
| * after the pivot value. The pivot value is now sorted. | |
| * Repeat the process recursively on the values less than |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Radix Sort: Radix (or base) means: "the base of a | |
| * system of numeration." Radix sorts by analyzing the | |
| * place values of each number. Each number must be a | |
| * whole number, or positive integer. Radix sort can be used | |
| * with a variety of base values, though here I focus | |
| * only on our decimal base 10 system. | |
| * | |
| * Process: | |
| * Create an auxiliary array with a length of ten (one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Title: Singly Linked List | |
| * Author: Dylan Landry | |
| * Date: Wed 26 Jun 2019 13:38:38 EDT | |
| * Permalink: https://gist.github.com/dyllandry/371505391a608abb9d979a1ea258cff9 | |
| * | |
| * Description: | |
| * A kind of data structure similar to a train. | |
| * Each node, a container for a value, knows only of the node ahead of it. | |
| * The list keeps references to the head node, the tail node, and the total |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Title: Doubly Linked List | |
| * Author: Dylan Landry | |
| * Date: Wed 26 Jun 2019 16:00:15 EDT | |
| * Permalink: https://gist.github.com/dyllandry/12d0a2f7f1b1cfc22169b1990bd89c2d | |
| * | |
| * Description: | |
| * A kind of data structure similar to a train. | |
| * Each node, a container for a value, knows of the node ahead of it and behind | |
| * it. The list keeps references to the head node, the tail node, and the total |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Toggles a touchpad on/off. | |
| # Might only work computers that use xinput. | |
| DEVICE_NAME="SynPS/2 Synaptics TouchPad" | |
| ID=$(xinput list --id-only "$DEVICE_NAME") | |
| IS_ENABLED=$(xinput --list-props "$DEVICE_NAME" | grep "Device Enabled" | grep -o "[01]$") | |
| if [ $IS_ENABLED -eq 0 ]; then | |
| xinput set-prop $ID "Device Enabled" 1 |
OlderNewer