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
class Node: | |
visited = None | |
data = None | |
adjacent = None | |
def __init__(self, value): | |
self.data = value | |
self.adjacent = [] | |
self.visited = False | |
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
[alias] | |
merge-release-major = !sh ../gitscripts/merge-release-major.sh | |
merge-release-minor = !sh ../gitscripts/merge-release-minor.sh | |
merge-release-patch = !sh ../gitscripts/merge-release-patch.sh |
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
def merge_sort(array: List) -> List: | |
if len(array) < 2: | |
return array | |
middle = floor(len(array)/2) | |
left = merge_sort(array[:middle]) | |
right = merge_sort(array[middle:]) | |
sorted_array = [] |
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
def bubble_sort(array): | |
for i in range(0, len(array)): | |
swapped = False | |
for j in range(0, len(array) - i - 1): | |
if array[j] > array[j + 1]: | |
array[j], array[j + 1] = array[j + 1], array[j] | |
swapped = True | |
if not swapped: |
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 | |
# | |
# Runtime complexity: O(n^2) | |
# Space complexity: O(1) | |
## | |
def insertion_sort(arr, detail = False): | |
for i in range(1, len(arr)): | |
j = i |
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 | |
# | |
# Runtime Complexity: O(n^2) | |
# Space Complexity: O(1) | |
## | |
def selectionSort(arr, detail = False): | |
for i in range(len(arr)): | |
min = i |
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
<?php | |
function sieve_of_eratosthenes($max) { | |
$flags = array_fill(0, $max, true); | |
$flags[0] = $flags[1] = false; | |
foreach ( $flags as $index => &$is_prime ) { | |
if ( $is_prime ) { | |
echo $index . "<br>\n"; | |
for( $i = $index*$index; $i < $max; $i +=$index ) |
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
def sieve_of_eratosthenes(max): | |
flags = [True] * max | |
flags[0] = flags[1] = False | |
for (i, isPrime) in enumerate(flags): | |
if isPrime: | |
print(i) | |
for n in range(i*i, max, i): | |
flags[n] = False |
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
def prime(n): | |
if n == 2: | |
return True | |
elif n % 2 == 0: | |
return False | |
max = math.ceil(math.sqrt(n)) | |
for i in range(3,max,2): | |
if n % i == 0: |
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
class BST(object): | |
root = None | |
def search(self, data): | |
return self._binarySearch(data, self.root) | |
def _binarySearch(self, data, root): | |
if root is None: | |
return False | |
elif root.data == data: |