swati4agrawal
BAN USERI was also asked a similar question once.
We can use array to implement hashtable
and for collisions we can use self balancing trees like AVL or red black trees so that the searching time is logN
I was also asked a similar question once.
We can use array to implement hashtable
and for collisions we can use self balancing trees like AVL or red black trees so that the searching time is logN
Use Sorting using any nlogn method like heap sort
and then compare if u find more then 1 element , put it in another array...
void findunique(int arr[],int size)
{
int j=0,arr2[size];
heapsort(arr,size);
for(int i =0;i<size;i++)
{
if(i<size-1 && arr[i]==arr[i+1])
{
while(i<size-1 && arr[i]==arr[i+1])
i++;
arr2[j++]=arr[i];
}
}
}
I was also asked a similar question once.
- swati4agrawal April 24, 2013We can use array to implement hashtable
and for collisions we can use self balancing trees like AVL or red black trees so that the searching time is logN