🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Binary Search Tree Operations: all 15 questions

Quiz: Binary Search Tree Operations · Question 15 of 15

Why does inserting already sorted keys into a plain BST make operations slow?

Why does inserting already sorted keys into a plain BST make operations slow?

  1. A.The keys are stored twice
  2. B.Sorting the keys takes O(n log n)
  3. C.The root is deleted every time
  4. D.Every new key goes to the right, so the tree becomes a chain of height n and search becomes O(n)
Answer & explanation

Correct answer: Every new key goes to the right, so the tree becomes a chain of height n and search becomes O(n)

Self-balancing trees such as red-black trees (used by Java's TreeMap) prevent this.

Can you get the rest right without peeking?

Take the timed Quiz: Binary Search Tree Operations quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →