This is a working java code which is used for implementing trie data structure.
class TrieNode {
TrieNode[] arr;
boolean isEnd;
// Initialize your data structure here.
public TrieNode() {
this.arr = new TrieNode[26];
}
What I don't understand is how the memory allocation works with
TrieNode[] arr;
code. If it were something like this
class TrieNode {
int[] arr;
boolean isEnd;
// Initialize your data structure here.
public TrieNode() {
this.arr = new int[26];
}
I know that this allocates memory for 26 integers. It's better if you can explain how the memory allocation works for first code. (In compiler's perspective)
EDIT : Sorry if my question is unclear.What im asking is we create array with 26 elements in
new TrieNode[26];
How much memory is allocated?