Error in code segmentation fault
In your rehash function you were deleting oldtable inside for loop resulting in seg fault, do it outside.
Also increment currentsize inside while loop!
it works, but i am incrementing currentSize.
Yes but I saw you were incrementing it outside while loop. This way a chain of 4 nodes count as only 1.
its inside the for loop
i did everything, wrote cursize inside while loop still there is collision
in video sis didnt wrote currentsize++,
if i write currentsize++ inside rehash while loop, the size of the new table becomes 3 times.
Well it depends what your current size is! If its total number of entries in hashmap then it shoud be inside while loop, or if its indexes with values it should be outside.
Well that’s your choice to go with. I hope the doubt is clear to you.
but we are making current size = 0 inside rehash
in video sir didnt wrote currentsize++ inside reshash function,
if i write currentsize++ inside rehash while loop, the size of the new table becomes 3 times.
why ? just explain me this thing.
Yes no need to increment it in rehash as it is incremented in insert().
Also if you do increment it, then it becomes twice and not thrice.
got it thanks …
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.