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

Discussion

The searching technique that takes O(1) to find a data is :

  • A.Linear search
  • B.Binary search
  • C.Hashing
  • D.Tree

Answer: C

The technique is hashing.

A hash function computes the position of a key directly from the key itself, so a lookup goes straight to the right slot without comparing against other elements. With a good hash function and a low load factor, search takes constant time, O(1), on average.

Linear search takes O(n), binary search on a sorted array O(log n), and a balanced search tree O(log n); none of them finds an item in constant time.

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

Post your comment

Please log in or register to post a comment.