由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - binary tree node spacing algorithm help
相关主题
简单评价几本java 入门编程书籍why algorithm related question is often asked during interv
Who can help for DFS search program?新人请教java学习的问题
这里有人玩hadoop/hbase么?求一本算法的书
需要一个动态的List,不要ConcurrentModificationException有没有什么package 可以用来算cumulative distribution function?
怎样才能使一个算法用于不同的数据结构?请推荐本java algorithms advanced点的书
请问哪里能找到radixsort java code?请推荐JAVA DATA STRUCTURE 的书
应聘面试,做Java测试都有哪些内容求一个书的电子版。不知道是否有人有? (转载)
如何在java 1.4.2底下进行公钥加密,私钥解密Algorithms in Java 书的答案
相关话题的讨论汇总
话题: node话题: algorithm话题: tree话题: print话题: spacing
进入Java版参与讨论
1 (共1页)
z****n
发帖数: 28
1
I want to print out a tree and the display output is like
4
2 6
1 3 5 7
.....
There are two steps in my algorithm:
First, Using DFS, compute the necessary space for each node. Do the
depth-first traversal AND keep track of which nodes have children so that you
can then print the lines to the children. It is a recursive function.
Second, to use BFS to print node.
I tried to figure out the space for each node, but failed.
Thnaks a lot for your suggestion!
g*****g
发帖数: 34805
2
I don't see why you need DFS first,
use a Q, BFS is straight. Use a function to format
your number to fix length before prin out.

【在 z****n 的大作中提到】
: I want to print out a tree and the display output is like
: 4
: 2 6
: 1 3 5 7
: .....
: There are two steps in my algorithm:
: First, Using DFS, compute the necessary space for each node. Do the
: depth-first traversal AND keep track of which nodes have children so that you
: can then print the lines to the children. It is a recursive function.
: Second, to use BFS to print node.

1 (共1页)
进入Java版参与讨论
相关主题
Algorithms in Java 书的答案怎样才能使一个算法用于不同的数据结构?
Recommend a Book about Algorithm? (转载)请问哪里能找到radixsort java code?
一本用Java进行算法面试的好书 (转载)应聘面试,做Java测试都有哪些内容
请junior level对算法要求有多高?如何在java 1.4.2底下进行公钥加密,私钥解密
简单评价几本java 入门编程书籍why algorithm related question is often asked during interv
Who can help for DFS search program?新人请教java学习的问题
这里有人玩hadoop/hbase么?求一本算法的书
需要一个动态的List,不要ConcurrentModificationException有没有什么package 可以用来算cumulative distribution function?
相关话题的讨论汇总
话题: node话题: algorithm话题: tree话题: print话题: spacing