Whenever I solve a question using the Keyword Tree / Trie data-structure, I implement it using pointers. But I have seen many programmers implementing trie using arrays.
What are the downsides of using the Pointers implementation (if at all) , as compared to the Arrays implementation ?
Happy Coding !
Pointers dynamically allocate memory which takes a bit more time. In array implementation you already have a fixed size declared- this saves time. So you see there is a trade-off between time and memory. Both are equally efficient under normal circumstances. Only when the constraints are too tight you may need to choose between the two.