📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    In a code flow involving frequent insertions and

    deletions, which type of Binary Search Tree is preferred to guarantee O(log n) time complexity for these operations in the worst case?
    A Unbalanced BST Correct Answer Incorrect Answer
    B Skewed BST Correct Answer Incorrect Answer
    C Complete BST Correct Answer Incorrect Answer
    D Self-balancing BST (e.g., AVL tree, Red-Black tree) Correct Answer Incorrect Answer
    E Full BST Correct Answer Incorrect Answer

    Solution

    Self-balancing BSTs like AVL trees and Red-Black trees automatically adjust their structure through rotations to maintain a logarithmic height, thereby guaranteeing O(log n) time complexity for search, insertion, and deletion even in the worst case.

    Practice Next
    ask-question