Is there strong reason not to include multiple node pointers in a node to use in more than one data structure?

Take for example the assignment I'm working on. We're to use a binary search tree for one piece of a set of data and then a linked list for another piece in the set. The suggested method by the professor was: struct treeNode { data * item; treeNode *left, *right; }; struct listNode { data * item; listNode *next, *prev; }; class collection { public: ........ } Where data is a class containing the particulars of each record. Obviously as it's set up, a treeNode can't exist in the linked list. Wouldn't it be much simpler to: struct node { data * item; node *listNext, *listPrev, *treeLeft, *treeRight; }; then we can declare: node * listHead; node * treeRoot; and include both insertion algorithms into the class. Is there something I'm missing?

以上就是Is there strong reason not to include multiple node pointers in a node to use in more than one data structure?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏