Binary search tree insertion, lookup, and deletion walkthroughs.
Easy Explanation
BST operations follow left-smaller and right-larger rules to search, insert, and delete values efficiently.
Operations
0
Tree
0 nodes / h=0
Progress
t:0 s:0
Mutations
i:0 d:0
Press Play or Step to start execution.
Initial Tree
empty
Current Frame
empty
Final Output
empty
Current Operation
n/a
Script
n/a
function search(node, target):
while node is not null:
if target == node.value:
return node
if target < node.value:
node <- node.left
else:
node <- node.right
return null
function insert(node, value):
if node is null:
return new Node(value)
if value < node.value:
node.left <- insert(node.left, value)
else if value > node.value:
node.right <- insert(node.right, value)
return node