遍历二叉树(广度,深度,递归,非递归).docVIP

  • 1
  • 0
  • 约1.29万字
  • 约 18页
  • 2016-11-28 发布于重庆
  • 举报
遍历二叉树(广度,深度,递归,非递归)

import?java.util.*; ? class?Node?{ ????Node?left; ????Node?right; ????int?key; ? ????public?Node(int?key)?{ ????????this.key?=?key; ????} } ? public?class?BTree?{ ???? ????Node?root; ? ????/** ????*????the?constructor ????**/ ????public?BTree()?{ ????????this.root?=?null; ????} ? ????public?BTree(int[]?array)?{ ???????? ????????if?(array?==?null?||?array.length?==?0)?{ ????????????throw?new?IllegalArgumentException(); ????????} ????????root?=?new?Node(array[0]); ????????QueueNode?queue?=?new?LinkedListNode();? ????????queue.offer(root); ????????int?i?=?1; ??????

文档评论(0)

1亿VIP精品文档

相关文档