Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hi Alexey,
- I just realized that I think I misunderstood your question about tree implementation. I think you were trying to ask about the underlying implementation (object/node structure). I mistakenly thought you were asking which pre-existing structures in the language that I would use ( so I mentioned Java's existing TreeNode class). Sorry about the confusion, but I just wanted to address the question as you asked it.
- Regarding low level implementation, each node would be a class which stored a value for the character it represented, an integer for the frequency of appearance, as well as a leftPointer and rightPointer. Depending on the implementation, there may also be a parent pointer. In C syntax, the struct would be as follows:
- ```
- struct Node {
- char character;
- int frequency;
- struct Node *leftPointer;
- struct Node *rightPointer;
- };
- ```
- Sorry for the inconvenience. Have a great day!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement