DSA
    intermediate

    Binary Search Tree (BST)

    Binary Search Tree

    O(h) ops
    Ready

    Binary Search Tree Structure

    Ready to perform BST operations

    Tree is empty. Insert a value to get started.
    Normal
    Visiting
    New
    Found
    Height
    0
    Nodes
    0
    Operation
    complete
    Path Length
    0

    In-order traversal

    Sequence

    Keys 50, 30, 70, 20, 40 were inserted into an empty BST. Order the keys as an in-order traversal visits them.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    1. 1Drop a step here
    2. 2Drop a step here
    3. 3Drop a step here
    4. 4Drop a step here
    5. 5Drop a step here
    5 pieces left to place

    Test your knowledge

    20 questions
    Question 1 of 20
    Score: 0

    What is the worst-case time complexity of searching in a BST?

    When to reach for this

    • When you need to maintain a **Sorted** collection
    • When you need fast Lookup, Insert, and Delete (O(log n))
    • Finding the closest value, floor, or ceiling

    Interview Questions

    Facebook
    Amazon
    Bloomberg
    Microsoft
    Apple
    Amazon
    Google
    Google
    Airbnb
    Microsoft

    Love this visualization?

    Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.

    100% free • No credit card required