Wicked Strategery

Where servers serve, routers route, and configulators configulate

Simple Tree

Written by: Doug Jenkinson

Article

I found this bit of code amongst my collection of code-snippets. It's a fairly simple program that reads a tree from a file and "pretty-prints" it to stdout.

For example, given this input file:

|blue |green green|yellow yellow|red

Would result in this tree:

blue green   yellow     red

It's implemented via an N-ary tree, without the restriction that each node must have N children. The only restriction is that the value of a node must be unique.

I've used variants of this in a number of places, handy for ensuring a tree as stored in memory matches what I think it should.

Feel free to download it and reuse it.


Metadata


Revisions

  • v1.0 (4 Jan 2006) - Article published.

Tags

About the Author

Doug Jenkinson is an avid technology aficionado and Software Engineer with Hyland Software, Inc. / entrepreneur in Copley, OH.

Read More...

Linquistory

"The Wørd" of the Night: Truthiness, courtesy of Stephen Colbert

Wikiality

Breadcrumbs

More Site Updates!

Yahoo's Design Tools

Application Suites vs. Specialized Applications

Site Updates!

Simple Tree

Personal Links

LinkedIn

Google Profile

My del.icio.us

twitter

My flickr

My ClaimID

Projects

twitlbl

Site Updates

I've added some spiffy new features to my site. You can read all about them in the changelog.

Internet Quote

"Yeah man, I tell ya what, man. That dang ol' Internet, man. You just go on there and point and click. Talk about W-W-dot-W-com. An' lotsa nekkid chicks on there, man. Click. Click. Click. Click. Click. It's real easy, man." - Boomhauer, King of the Hill

Feeds

RSS OPML