top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Java: Need a fully functional hash table with time complexity for search O(n)

+1 vote
485 views

I need a fully functional hash table with time complexity for search O(n). Can someone please help me?

posted Sep 30, 2013 by Vivek Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Hash with o(n) ????, hash has complexity as o(1). Are you sure about your question?

1 Answer

0 votes

For search O(n) ,then you can use array of fixed size & collision can be avoided by chaining using linked
list in this case worse case when all n elements maps to the same index , linear search will take O(n)
time to find the element. In order to get the O(1) search ,Create an array of size max( all a[i]) and then map each element corresponding to their index.

answer Oct 1, 2013 by Arvind Singh
...