473,407 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

implementing trees in STL

Hi,

which stl class is good for creating search trees? I am looking for
something flexible, that allows me to search for a required state (of
matrices, graphs, etc.) quickly.

thanks in advance,
Craig.
Jul 19 '05 #1
6 5398
C++ Shark wrote:
Hi,

which stl class is good for creating search trees? I am looking for
something flexible, that allows me to search for a required state (of
matrices, graphs, etc.) quickly.


Check out

std::map and std::multimap.

Jul 19 '05 #2
Gianni Mariani wrote:
C++ Shark wrote:
Hi,

which stl class is good for creating search trees? I am looking for
something flexible, that allows me to search for a required state (of
matrices, graphs, etc.) quickly.


Check out

std::map and std::multimap.


Those are not really good for *creating* search trees, but they are
probably implemented *using* search trees (or possibly skip-lists -- I'd
be interested to know if any implementations have used skip-lists
instead of balanced search trees).

For creating search trees, I don't see any particular part of the
standard library that would be very useful. It's the kind of thing that
is usually done in a class.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

Jul 19 '05 #3
In article <U3*****************@newsread3.news.pas.earthlink. net>,
us*********************@neverbox.com says...

[ ... ]
Those are not really good for *creating* search trees, but they are
probably implemented *using* search trees (or possibly skip-lists -- I'd
be interested to know if any implementations have used skip-lists
instead of balanced search trees).


I've yet to see any based around skip lists -- the range of variation
I've seen so far has been from Red/Black trees to AVL trees.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 19 '05 #4
Jerry Coffin wrote:
....

I've yet to see any based around skip lists -- the range of variation
I've seen so far has been from Red/Black trees to AVL trees.


What's a skip list ?

Jul 19 '05 #5
In article <bk********@dispatch.concentric.net>, gi*******@mariani.ws
says...
Jerry Coffin wrote:
...

I've yet to see any based around skip lists -- the range of variation
I've seen so far has been from Red/Black trees to AVL trees.


What's a skip list ?


The inventor's original paper from the Communications of the ACM is
available here:

ftp://ftp.cs.umd.edu/pub/skipLists/skiplists.pdf

Shortcomings: the C++ standard requires logarithmic complexity for
std::map, std::multimap, std::set and set::multiset in the worst case,
and while skip lists provide good expected complexity, IIRC their worst
case is linear.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 19 '05 #6
Gianni Mariani <gi*******@mariani.ws> writes:
Jerry Coffin wrote:
...
I've yet to see any based around skip lists -- the range of
variation I've seen so far has been from Red/Black trees to AVL
trees.


What's a skip list ?


It's a list where some of the nodes contain additional pointers to
nodes farther away - every 2nd node points 2 nodes away, every 4th
node points 4 nodes away etc. - every Nth node has an additional
pointer N nodes away (called a pointer of order N).
In a perfect skip list, searching is always O(log n), but insertion
and deletion are O(N) - so you can use randomized skip lists, where
the probability that a given node gets a pointer of order N is
1/2^N - in worst case, this leads to an ordinary list, but in
average, it's as good as a perfect skip list.

for further reading, see
W. Pugh, Skip lists: A probabilistic alternative to balanced trees.
In Proc. Workshop of Algorithms and Data Structures, p. 437-449,
1989, Lecture Notes in Computer Science 382

W. Pugh, Skip lists: A probabilistic alternative to balanced trees.
Comm. ACM, 33(6):668-676, 1990
HTH & kind regards
frank

--
Frank Schmitt
4SC AG phone: +49 89 700763-0
e-mail: frankNO DOT SPAMschmitt AT 4sc DOT com
Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: barnesc | last post by:
Hi again, Since my linear algebra library appears not to serve any practical need (I found cgkit, and that works better for me), I've gotten bored and went back to one of my other projects:...
3
by: ptrSriram | last post by:
Can someone help me with an algorithm to merge two binary search trees. One method I thought of was to flatten both the trees into sorted lists(inorder traversal),merge those two sorted lists,...
2
by: trusiki | last post by:
I am trying to use C# for my program that deals with manipulation of trees (i.e. finding distance between different nodes, assigning labels to nodes, storing trees, etc.). I know I can probably...
2
by: Ole Nielsby | last post by:
First, bear with my xpost. This goes to comp.lang.c++ comp.lang.functional with follow-up to comp.lang.c++ - I want to discuss an aspect of using C++ to implement a functional language, and...
9
by: raylopez99 | last post by:
What's the best way of implementing a multi-node tree in C++? What I'm trying to do is traverse a tree of possible chess moves given an intial position (at the root of the tree). Since every...
17
Ganon11
by: Ganon11 | last post by:
Hey guys, OK, taking care of this beforehand; I AM a student in a university. This IS part of my homework, and (as a moderator), I'm doing my best to follow the posting guidelines I work so hard...
2
by: parasuram | last post by:
Hi friends ............. this is a question regarding the data structures trees Pleas post it if possible with in 2 days I will thankful if some body could help doing this. Operating...
5
by: nandor.sieben | last post by:
I am using a small set of functions that implements an n-ary tree. The library is disscusses here: ...
6
by: rsprawls | last post by:
I found a disk for a b-tree algorithm that I purchased back in 93 or so. I'd hoped to find this, but now I'd like to know how worthwhile are b-trees in today's advancements? This is old C code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.