CUET PG 2025 Computer PYQ — In a binary search tree, the worst case time compiexity of insert… | Mathem Solvex | Mathem Solvex
Tip:A–D to answerE for explanationV for videoS to reveal answer
CUET PG 2025 — Computer PYQ
CUET PG | Computer | 2025
In a binary search tree, the worst case time compiexity of inserting and deleting a key is:
Choose the correct answer:
A.
O(lg n) for insertion and O(lg n) for detetion
B.
O(n) for insertion and O(lg n) for detetion
C.
O(n) for insertion and O(n) for detetion
(Correct Answer)
D.
O(lg n) for insertion and O(n) for detetion
Correct Answer:
O(n) for insertion and O(n) for detetion
Explanation
Mathematical Logic:
Agar tree mein n nodes hain aur tree skewed hai, toh kisi bhi node tak pahunchne ke liye humein root se leaf tak saare nodes traverse karne padte hain.
Worst-case Height (h):
Ek skewed tree ke liye:
h=n−1
Insertion & Deletion Complexity:
In dono operations ke liye pehle sahi position dhoondhni padti hai, jiska samay height (h) par nirbhar karta hai:
Time Complexity=O(h)
Sutradhar (Substituting) h=n karne par:
Worst-case Complexity=O(n)
Explanation
Mathematical Logic:
Agar tree mein n nodes hain aur tree skewed hai, toh kisi bhi node tak pahunchne ke liye humein root se leaf tak saare nodes traverse karne padte hain.
Worst-case Height (h):
Ek skewed tree ke liye:
h=n−1
Insertion & Deletion Complexity:
In dono operations ke liye pehle sahi position dhoondhni padti hai, jiska samay height (h) par nirbhar karta hai: