Initializing every bucket's pointer to NULL

By initializing every bucket’s pointer to Null, are we creating individual buckets that could be linked later?

Hey @gargprachi1203
We make pointer as null when new node is created, which we generally do while inserting i.e linking a new node to already existing linked list.

If I initialize every element to NULL and then link them later, using a while loop, would it work?

Yes It will work too but we generally don’t do like this because you have to maintain a hashmap where key is nos and value is nodes

1 Like

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.