0
0
Data Structures Theoryknowledge~5 mins

Insertion in BST in Data Structures Theory - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a Binary Search Tree (BST)?
A Binary Search Tree is a tree data structure where each node has at most two children. The left child's value is less than the parent's value, and the right child's value is greater than the parent's value. This property helps in efficient searching, insertion, and deletion.
Click to reveal answer
beginner
What is the main rule to follow when inserting a new value into a BST?
When inserting, compare the new value with the current node's value. If it is smaller, go to the left child; if larger, go to the right child. Repeat this until you find an empty spot where the new value can be inserted as a leaf node.
Click to reveal answer
beginner
Why do we insert new nodes as leaf nodes in a BST?
New nodes are inserted as leaf nodes because the BST property requires that all nodes to the left are smaller and all to the right are larger. Inserting at a leaf maintains this order without disturbing the existing structure.
Click to reveal answer
intermediate
What happens if you try to insert a value that already exists in the BST?
Typically, BSTs do not allow duplicate values. If a duplicate is found during insertion, the process stops or handles it based on specific rules, such as ignoring the insertion or storing duplicates in a special way.
Click to reveal answer
intermediate
How does the insertion operation affect the height of a BST?
Insertion can increase the height of the BST by one if the new node is added at the deepest level. Over many insertions, if values are inserted in sorted order, the BST can become unbalanced and behave like a linked list, increasing height and reducing efficiency.
Click to reveal answer
Where do you insert a new value in a BST if it is smaller than the current node's value?
AAnywhere in the tree
BIn the right subtree
CAt the root
DIn the left subtree
What is the first step when inserting a new value into a BST?
ACompare the new value with the root node
BInsert the value at the leftmost leaf
CDelete the root node
DBalance the tree
What happens if you insert values in sorted order into a BST?
AThe BST becomes balanced
BThe BST becomes a linked list
CThe BST height decreases
DThe BST deletes nodes
Can a BST contain duplicate values?
AYes, duplicates are always allowed
BNo, duplicates are never allowed
CUsually no, but some BSTs handle duplicates specially
DDuplicates replace existing nodes
Where is a new node inserted in a BST?
AAs a leaf node
BAt the root
CIn the middle of the tree
DAt the rightmost node always
Explain the step-by-step process of inserting a new value into a Binary Search Tree.
Think about how you decide where to place the new value by comparing it with existing nodes.
You got /5 concepts.
    Describe how inserting values in sorted order affects the shape and efficiency of a BST.
    Consider what happens when every new value is always greater than the previous.
    You got /4 concepts.