开发者

Binary Tree applications - Storing dates

I'm working on a simple app and the specs mandate that a binary search tree must be used for storing dates in DD/MM/YYYY format. Question is, I'm having a hard time visualizing the structure and how nodes shall b开发者_如何学运维e organized.

Sorry for being vague, but can I get some pointers?

Thanks for your time!


Basically what is required is that you make a comparator function which determines if a date is earlier or later (or equal) respective to another. You'd use this function to determine where to place a new node and/or if it already exists in the tree. The rest would work like a regular binary tree holding, say, Integers.

For example, you can put earlier dates as left children and later dates as right children.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜