1/7
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Tree insert function
def insert(root, val):
if not root:
return TreeNode(val) // create a node
if val > root.val:
root.right = insert(root.right, val)
elif val < root.val:
root.left = insert(root.left, val)
return rootBST - remove
def minValueNode(rootRecursion
writing functions that call themselves with smaller subproblems
depth first search (DFS)
traversing trees by exploring as deep as possible before backtracking
breadth first search
traversing trees level by level using a queue
deque()
double-ended queue

how to add / remove elements in deque
q = deque()
q.append(5) # [5]
q.append(10) # [5, 10]
q.appendleft(1) # [1, 5,10]
q.popleft() # remove from left [5,10]
q.pop() # remove from right [5]