Skip to content

Instantly share code, notes, and snippets.

View baoqger's full-sized avatar

baoqger baoqger

  • China
View GitHub Profile
@baoqger
baoqger / binary-tree.cpp
Created August 12, 2020 13:57
binary tree in cpp
/*
LAB 3
Objectives 3
Binary tree's are data structures that have a hierarchical form and represent trees
whose elements have a maximum number of two children. These children are called the
left and the right child. The binary tree root represents the top node.
A node that has at least one child is considered a parent of its child.
A leaf is a node that has no children.
*/
@baoqger
baoqger / double-link-list.cpp
Created August 11, 2020 07:11
double link list in c++
#include <iostream>
#include <list>
using namespace std;
class Hash {
int BUCKET;
list<int> *table; // pointer to an array containing buckets
public:
import { defaultMemoize } from "./memoizedSelector";
import { slowFunction } from "./slowFunction";
// run slowFunction without memoization
console.log("First call of slowFunction(2)");
let pre = new Date();
slowFunction(2);
console.log("It takes" + ((new Date()).valueOf() - pre.valueOf())/1000 + "seconds \n");
console.log("Second call of slowFunction(2)");
pre = new Date();
export function slowFunction(val: number): number {
const pre = new Date();
while (true) {
const now = new Date();
if (now.valueOf() - pre.valueOf() > 2000) {
break;
}
}
return val;
}
export type AnyFn = (...args: any[]) => any;
export type ComparatorFn = (a: any, b: any) => boolean;
export type MemoizedProjection = {
memoized: AnyFn;
reset: () => void;
setResult: (result?: any) => void;
};