You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson covers the core operations on Binary Search Trees (BSTs) — insertion, deletion, and searching — as required by the OCR A-Level Computer Science (H446) specification. These operations are fundamental to understanding how tree-based data structures work.
To search for a value in a BST, start at the root and use the ordering property to decide whether to go left or right.
function search(node, value)
if node == null then
return false
end if
if value == node.data then
return true
else if value < node.data then
return search(node.left, value)
else
return search(node.right, value)
end if
end function
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.