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
#include <iostream> | |
using std::cout; | |
using std::cin; | |
using std::endl; | |
#include <ctime> | |
using std::clock_t; | |
#include <map> | |
using std::map; |
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
# Dynamic Programming for calculating nth Fibonacci Number | |
# Ian Taylor, 2017 | |
def dp_fib(n, memo={}) | |
return memo[n] unless memo[n].nil? | |
(n <= 2) ? f = 1 : f = dp_fib(n - 1, memo) + dp_fib(n - 2, memo) | |
memo[n] = f | |
f | |
end | |
# standard recursive Fibonacci |
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
; Applicative Order Y-Combinator | |
(define Y | |
(lambda (f) | |
((lambda (x) (x x)) | |
(lambda (x) (f (lambda (y) ((x x) y))))))) |
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
package main | |
import ( | |
"fmt" | |
"log" | |
) | |
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
See See Cormen, et al, 3rd ed. page 592 |
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
// Heapsort Go, Ian Taylor 2017 | |
// A very simple heapsort, | |
// emphasizing algorithmic clarity over optimization | |
package main | |
import ( | |
"fmt" | |
) |
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
// Quicksort Go, Ian Taylor 2017 | |
// A very simple quicksort implementation with a randomized pivot, | |
// emphasizing algorithmic clarity over optimization | |
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" |
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
package main | |
import ( | |
"fmt" | |
) | |
func binary_search_recursive(A []int, key, low int, high int) int { | |
if low > high { | |
return -1 | |
} |
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
// Merge Sort Go, Ian Taylor 2017 | |
// A very simple mergesort implementation, emphasizing algorithmic clarity over optimization | |
package main | |
import ( | |
"fmt" | |
) | |
// sort an unsorted array in ascending order |
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
; return a new list, where elements that do not | |
; meet the conditions of the filter function are removed | |
(define myfilter | |
(lambda (func lat) | |
(cond | |
((null? lat) (quote ())) | |
((func (car lat)) (cons (car lat) | |
(myfilter func (cdr lat)))) | |
(else | |
(myfilter func (cdr lat)))))) |