CS163_Week8 - CS163: Data structures Week 8: Trees (cont.)...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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 2-3 (evaluate what we learned) B-Trees AVL 2-3-4 red-black trees dbtien Data structures Discuss 2-3 Trees A 2-3 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 2-3 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 2-3 Trees So, if 2-3 trees are so good, why not have nodes that can have more data items and more than 3 children? Well, remember why 2-3 trees are great? because they are balanced and that balanced structure is pretty easy to maintain dbtien Data structures Discuss 2-3 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 2-3 Trees But, with binary search trees balance is hard to maintain A 2-3 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 2-3 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 B-Trees Tables stored externally can be searched with B- Trees. B-Trees are a more generalized approach than the 2-3 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 B-Trees 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 B-Trees 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.

Page1 / 49

CS163_Week8 - CS163: Data structures Week 8: Trees (cont.)...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online