Hashmap is necessary?

Isn’t it better to use ArrayList or HashSet() intead of using HashMap for proceessed nodes/vertices…?

Hello Monica,
As per your question, you are saying that why we can’t use Array List or Hash Map for processed nodes.
Yes, you can definitely use that but you must know that Hash Map works in constant time.
But Array List doesn’t, and If I talk about the Hash Set then it also Hash Map for its internal use.
The disadvantage with Hash Set () is that it can’t have duplicates and it works slower than Hash Map

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.