View on GitHub

csc263

Notes for CSC263 - Data Structures and Analysis

Back to index

Dictionaries

Represents a (mutable) set $S$ of elements with keys

Operations

Binary Search Trees

BST Property

For each node, keys in left subtree <= root key <= keys in right subtree.

Traversals
Rotations

Set Operations on BSTs

search(D, x)

def search(D, x):
    if (x == D.root):
        return D.root
    elif (x < D.root):
        return search(D.left_child, x)
    else:
        return search(D.right_child, x)