Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of the following will return a result most quickly for searching a given key?

  • A.Unsorted Array
  • B.Sorted Array
  • C.Sorted linked list
  • D.Binary Search Tree

Answer: D

Correct answer: Binary Search Tree

A balanced binary search tree finds a key in \( O(\log n) \) comparisons, halving the search space at each step.

An unsorted array and a sorted linked list both require \( O(n) \), the list because it cannot be indexed and so cannot be bisected however well ordered it is. A sorted array also permits binary search at \( O(\log n) \), so the two are comparable on lookup - but the tree keeps that performance while supporting insertion and deletion in \( O(\log n) \), where the array would need elements shifted.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.