January 12, 2011 Ted Holt
Note: The code accompanying this article is available for download here.
Last week, I wrote about linked lists. Each node in the list points to another node. Binary trees differ from linked lists in only one way–each node has two pointers to other nodes. How you label these pointers is up to you, but most people choose to call them left and right.
Here’s a data structure that defines a node with left and right pointers.
D Record ds qualified D Name 20a D City 12a D Left * D Right *
A node that points to one