Instantly share code, notes, and snippets.

# alejandroerickson

• Sort options
Last active Aug 15, 2016
Check if binary tree t2 on n nodes is a subtree of binary tree t1 on n nodes in O(m+(1+epsilon)n) time
View contains_subtree.c
 #include #include #include #define max(a,b) ((a>b)?a:b) #define timeit(a,b){ \ start=clock(); \ a; \ end=clock(); \
Last active Aug 14, 2016
Given N rectangles, check whether they cover a rectangle exactly (with no overlaps).
View isBigRect.py
 def isBigRect(rectangles): if rectangles==[]: return True L=processBoundaries(rectangles,leftOrRight='left') R=processBoundaries(rectangles,leftOrRight='right') # print L, R if L==False or R==False or not len(L)==len(R): return False L[-1][0]=R[-1][0] R[0][0]=L[0][0]
Created Aug 3, 2016
get uint32_t length
View int_length_bit_twiddle.c
 #include #include void print_bits(uint32_t x); uint32_t uint32_smear_right(uint32_t x){ x = x | x>>1; x = x | x>>2; x = x | x>>4; x = x | x>>8;
You can’t perform that action at this time.