LearnFrenzy
Sign in Take a free test

Data Structures in Java · Data Structures in Java MCQ · Question 9

Inserting sorted keys into a plain BST Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 9 Back to Exercise

Keys 1, 2, 3, …, n are inserted in that order into an unbalanced binary search tree. What is the cost of a search afterwards?

  • A O(1)
  • B O(log n)
  • C O(n) Correct
  • D O(n log n)
Correct Answer: Option C

Every key goes to the right of the previous one, so the tree degenerates into a chain of height n.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links