Thread: no tree data structure in STL

  1. #1
    Banned
    Join Date
    Nov 2007
    Posts
    678

    no tree data structure in STL

    Why there is no Tree data structure in STL?
    Is it not needed so much? Or can it be done easily with other Data Structures?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    My guess is that trees were not included since they (as in balanced binary trees) are typically used to implement sets and maps, and these are already included.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by manav View Post
    Why there is no Tree data structure in STL?
    Is it not needed so much? Or can it be done easily with other Data Structures?
    STL provides containers, not data structures. The std::map container is, most likely, implemented as a binary tree. It must be so, in order to guarantee the time complexity specified by STL. But STL does not technically concern itself with such things -- it makes certain time guarantees and iterator guarantees, nothing else. A std::map guarantees that the time to access a member is O(log n) in the number of members and that iteration is roughly linear. In practice, this is achieved through a tree, but you can't make that assumption.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Binary Tree Search
    By C++Newbie in forum C++ Programming
    Replies: 7
    Last Post: 04-05-2011, 01:17 AM
  2. List Tree - New data structure
    By sincoder in forum C++ Programming
    Replies: 5
    Last Post: 08-12-2008, 01:33 PM
  3. Replies: 6
    Last Post: 06-09-2006, 12:44 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM