Solved

Implementing a tree in C++/Linux

Posted on 2010-09-10
6
585 Views
Last Modified: 2012-05-10
Hello,

I'm trying to implement a generic tree structure in a C++ Linux project.  There doesn't seem to be any standard tree container in C++, though.

Does such a container exist?

Thanks,
Tim
0
Comment
Question by:tmitch68
6 Comments
 
LVL 3

Expert Comment

by:packratt_jk
ID: 33648258
Not in standard c++, no.
0
 

Expert Comment

by:shaz_moony
ID: 33648259
yes
0
 

Author Comment

by:tmitch68
ID: 33648282
Can you tell me what it is?
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 3

Assisted Solution

by:packratt_jk
packratt_jk earned 100 total points
ID: 33648293
There might be something in the STL - here's a tutorial for a linked list:

http://www.yolinux.com/TUTORIALS/LinuxTutorialC++STL.html

0
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 33648777
Maybe http://tree.phi-sci.com/ ("tree.hh: an STL-like C++ tree class") can help you.
0
 
LVL 32

Assisted Solution

by:phoffric
phoffric earned 200 total points
ID: 33649476
I always thought that an STL map would be implemented by a tree. (They even teach it that way in C++ courses when you have to design your own map.)

Here is one quote from a search to support this view:

"While the C++ standard does not specifically require that the map container be implemented using any specific data structure, the time complexity requirements imposed by the standard for each map operation suggest a balanced binary search tree. Many STL implementations use a red/black tree to implement map. Map operations such as searching for an element or adding an element are O(log n) operations. Logarithmic time complexity for these common operations means that maps are suitable for storing a collection of almost any size, including large collections. Also, map provides bidirectional iterators."

http://frank.mtsu.edu/~csjudy/STL/Map.html
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question