Skip to content

Instantly share code, notes, and snippets.

@pikeas
Created October 9, 2011 16:38
Show Gist options
  • Save pikeas/1273891 to your computer and use it in GitHub Desktop.
Save pikeas/1273891 to your computer and use it in GitHub Desktop.
Recursion depth exceeded
class Node:
def __init__(self, b, e, data, L, R):
self.b = b
self.e = e
self.L = L
self.R = R
self.data = data
class SegmentTree:
def __init__(self, N, quads):
def _init(b, e):
if b is e:
data = 'foo' #No dependency
return Node(b, e, data, None, None)
else:
mid = (b + e ) / 2
L = _init(b, mid)
R = _init(mid + 1, e)
data = 'foo' #Data depends on values in L and R
return Node(b, e, q, L, R)
self.root = _init(1, N)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment