Advertisement
Guest User

Interview Followup

a guest
Oct 23rd, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. Hi Alexey,
  2.  
  3. 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.
  4.  
  5. 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:
  6.  
  7. ```
  8. struct Node {
  9. char character;
  10. int frequency;
  11. struct Node *leftPointer;
  12. struct Node *rightPointer;
  13. };
  14. ```
  15.  
  16. Sorry for the inconvenience. Have a great day!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement