标题:请教大家一个问题
只看楼主
yuxudaoren
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2006-3-24
 问题点数:0 回复次数:0 
请教大家一个问题

The following represents a sample tree saved in a file.

The children of each node has an extra '\t'

at the beginning and the children of each

node are directly under it.

The tree can be very deep and each node can have 0 to many child nodes.

===========================

Root

V:\

FolderX

FolderA1

FolderD2

FolderB

FolderW1

FolderB2

D:\

FolderM

FolderQ1

FolderC2

============================

Please implement a program to load the whole tree into the memory from the tree file. The program should not only load the tree file above, but also load other similar tree files.

The tree data structure should be similar as.

Class Tree

{

string name;

int level; // the depth of the node from the root

Array children; // each object in the Array is the type Tree.

}

And then sort the child nodes of each node in the ascending order using IComparer interface.

Then print the tree out in the same tree file format.

将树载入内存可以看做是树的存储么? 能否定义结点类然后用左孩子——右兄弟的方法来做呢?
谢谢!~

2006-03-24 01:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-52400-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.376058 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved