This preview shows pages 1–12. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS163: Data structures Week 8: Trees (cont.) 7/2008 dbtien Data structures CS163: today? Continue Discussing Trees Examine more advanced trees 23 (evaluate what we learned) BTrees AVL 234 redblack trees dbtien Data structures Discuss 23 Trees A 23 tree is always balanced Therefore, you can search it in all situations with logarithmic efficiency of the binary search You might be concerned about the extra work in the insertion/deletion algorithms to split and merge the nodes... dbtien Data structures Discuss 23 Trees But, rigorous mathematical analysis has proved that this extra work to maintain structure is not significant It is sufficient to consider only the time required to locate an item (or a position to insert) dbtien Data structures Discuss 23 Trees So, if 23 trees are so good, why not have nodes that can have more data items and more than 3 children? Well, remember why 23 trees are great? because they are balanced and that balanced structure is pretty easy to maintain dbtien Data structures Discuss 23 Trees The advantage is not that the tree is shorter than a balanced binary search tree the reduction in height is actually offset by the extra comparisons that have to be made to find out which branch to take actually a binary search tree that is balanced minimizes the amount of work required to support ADT table operations dbtien Data structures Discuss 23 Trees But, with binary search trees balance is hard to maintain A 23 tree is really a compromise Searching may not be quite as efficient as a binary tree of minimum height but, it is relatively simple to maintain dbtien Data structures Discuss 23 Trees Allowing nodes to have more than 3 children would require more comparisons and would therefore be counter productive unless you are working with external storage and each node requires a disk access, then we use b trees which have the minimum height possible dbtien Data structures Discuss BTrees Tables stored externally can be searched with B Trees. BTrees are a more generalized approach than the 23 Tree With externally stored tables, we want to keep the search tree as short as possible; it is much faster to do extra comparisons at a particular node than try to find the next node. dbtien Data structures Discuss BTrees Every time we want to get another node, we have to access the external file and read in the appropriate information. It takes far less time to operate on a particular node (i.e., doing comparisons) once it has been read in. This means that for externally stored tables we should try to reduce the height of the tree...even if it means doing more comparisons at every node. dbtien Data structures Discuss BTrees Therefore, with an external search tree, we allow each node to have as many children as possible....
View
Full
Document
This note was uploaded on 11/03/2010 for the course CS 16x taught by Professor Tang during the Spring '10 term at Aachen University of Applied Sciences.
 Spring '10
 Tang
 Data Structures

Click to edit the document details