返回   cpper编程论坛 > C/CPP/TMP/GP
注册账号 论坛帮助 会员列表 日历事件 搜索 今日新帖 标记版面已读

回复
 
LinkBack 主题工具 显示模式
  #1 (permalink)  
旧 2007-10-15
初级会员
 
注册日期: 2006-11-18
住址: chn
帖子: 8
mjus 正向着好的方向发展
默认 AVL vs RED-BLACK tree

Regarding AVL & RB tree, I wonder who is better in terms of insert, find, delete, and overall (the named three actions). please provide your insight, thinking...
thank you !!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #2 (permalink)  
旧 2007-10-15
cat cat 当前离线
高级会员
 
注册日期: 2003-11-06
帖子: 1,563
文章: 6
cat 正向着好的方向发展
默认 回复: AVL vs RED-BLACK tree

google到了这条:

The Old Joel on Software Forum - AVL Trees vs. Red-Black Trees?

里面这段说得不错,不过具体效率很重要的话还是测一下的好,实现得很烂的RB-tree可能就会比实现得很好的AVL tree快一点。
引用:
It's been a long time since any data structure lectures, but my understanding is that in an AVL tree the difference between the shortest and longest path to from the root to any leaf is at most one. In a red-black tree the difference can be a factor of 2.

Both of these give O(log n) for look up, but balancing an AVL tree can require O(log n) rotations, whilst a red black tree will take at most two rotations to bring it into balance (though it may have to examine O(log n) nodes to decide where the rotations are necessary). The rotations themselves are O(1) operations since you are just moving pointers around.

You might also want to look up 2-3-4 trees, or more generally B trees for more balanced tree data structures.

Rob Walker
Tuesday, December 17, 2002
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #3 (permalink)  
旧 2007-10-16
初级会员
 
注册日期: 2006-11-18
住址: chn
帖子: 8
mjus 正向着好的方向发展
默认 回复: AVL vs RED-BLACK tree

To cat
实现得很烂的RB-tree可能就会比实现得很好的AVL tree快一点 ???
did you make a typo ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #4 (permalink)  
旧 2007-10-18
cat cat 当前离线
高级会员
 
注册日期: 2003-11-06
帖子: 1,563
文章: 6
cat 正向着好的方向发展
默认 回复: AVL vs RED-BLACK tree

一直听说AVL调整比较复杂貌似会比RB-Tree慢一点吧。没测过说不准。这种同一个O下的性能优势可能因为某个的实现上的失误泡汤的吧。
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #5 (permalink)  
旧 2007-10-20
初级会员
 
注册日期: 2006-11-18
住址: chn
帖子: 8
mjus 正向着好的方向发展
默认 回复: AVL vs RED-BLACK tree

please see & check the page below
Daniel K. O. - std::map and std:et based on AVL, not RB trees.

it is based on the sgi style, STL compatible AVLmap. As I tested it.
it does surpass sgi::RBmap. really cool. but it seems not what the
books say (usually rb is better than avl -- most books say so ...).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
回复

书签

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码
Trackbacks are 启用
Pingbacks are 启用
Refbacks are 启用


相似的主题
主题 主题作者 版面 回复 最后发表
请问sicp 2.63题 tomato 算法 3 2006-05-03 11:57 PM
[请问]Expression tree和一般的tree有什么区别阿? Karla 技术杂烩 2 2003-12-09 11:27 AM
functional的pattern match vs. OO的visitor vs. if/switch ajoo 技术杂烩 49 2003-09-22 04:51 PM
与树实现无关的树iterator ajoo 技术杂烩 74 2003-06-27 01:20 PM
从directory reader到tree iterator papercrane 技术杂烩 2 2003-04-15 03:16 PM


所有时间均为格林尼治时间 +9。现在的时间是 09:09 AM


Powered by vBulletin® 版本 3.7.0
版权所有 ©2000 - 2009,Jelsoft Enterprises Ltd.
(C) Copy Right All Right Reserved 2001 - 2007

Search Engine Friendly URLs by vBSEO 3.1.0