This file contains 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
function useTaskQueue(params: { | |
shouldProcess: boolean | |
}): { | |
tasks: ReadonlyArray<Task> | |
isProcessing: boolean | |
addTask: (task: Task) => void | |
} { | |
const [queue, setQueue] = React.useState<{ | |
isProcessing: boolean | |
tasks: Array<Task> |
This file contains 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
#################################### | |
# Copyright Christopher Abiad, 2013 | |
# All Rights Reserved | |
#################################### | |
__author__ = 'Christopher Abiad' | |
def find_missing_one(bit_index, A): | |
# there is only one item | |
if bit_index == 0: |
This file contains 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
#################################### | |
# Copyright Christopher Abiad, 2013 | |
# All Rights Reserved | |
#################################### | |
"""In-place quicksorting.""" | |
__author__ = 'Christopher Abiad' | |
from random import randrange |
This file contains 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
#################################### | |
# Copyright Christopher Abiad, 2013 | |
# All Rights Reserved | |
#################################### | |
"""Binary min-heap with a simple heapsort implementation. | |
Heap is stored entirely in an array (Python list) using the property that | |
for any node at position i, its two children can be stored at 2i and | |
2i + 1 without any collisions with other nodes. | |
""" |
This file contains 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
#################################### | |
# Copyright Christopher Abiad, 2012 | |
# All Rights Reserved | |
#################################### | |
__author__ = 'Christopher Abiad' | |
def mergesort(l): | |
n = len(l) | |
if n <= 1: |