sir can we make the return type as T , and in the case if the key is not present, we could return -1 or INT_MAX or anything else that indicated that the value is not present.
in the vedio you make it as T*
T search(string key)
{
int idx=hashfn(key);
node*temp=table[idx];
while(temp!=nullptr)
{
if(temp->key==key)
return temp->value;
temp=temp->next;
}
return -1; // or return INT_MAX;
}
Search function in hashtable
Hello @mzk1994 as you can make the return type as T.
T* means that you wil return the pointer or the starting address.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.