




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Indexing Chris Brooks Department of Computer Science University of San Francisco Department of Computer Science — University of San Francisco – p.1/
Often, when managing records, we want to do more thanjust find a record that matches a particular key. Find all records in a range, in order. Sort by one of several keys Also, records may not all fit into memory Department of Computer Science — University of San Francisco – p.2/
Some Possible Data Structures: Sorted List Find / Find in Range: fast Add / Remove: slow Unsorted List / Hash Table Add, Find, Remove fast: (hash) Find in Range: slow Binary Search Tree All operations are fast (O(lg n)) if the tree is balanced Trees look like a good choice - how to keep thembalanced? Department of Computer Science — University of San Francisco – p.4/
So far, we’ve assumed our entire data structure can fit intomain memory. What if it’s too large? Need to minimize the number of disk accesses Speaking practically, reading from the disk is much slower than reading from memory RAM: 50 nanoseconds disk: 5 milliseconds (100,000 times slower) Strategies Keep tree as shallow as possible Store records with adjacent keys in adjacent blockson disk Department of Computer Science — University of San Francisco – p.5/
6 16 3 8 13 18 7 11 12 14 17 2 2 5 Department of Computer Science — University of San Francisco – p.7/
How can we find an element in a 2-3 tree? Department of Computer Science — University of San Francisco – p.8/
Always insert at the leaves To insert an element: Find the leaf where the element would live, if it was inthe tree Add the element to that leaf Department of Computer Science — University of San Francisco – p.10/
Always insert at the leaves To insert an element: Find the leaf where the element would live, if it was inthe tree Add the element to that leaf What if the leaf already has 2 elements? Department of Computer Science — University of San Francisco – p.11/
5 6 7 7 5 6 Department of Computer Science — University of San Francisco – p.13/
4 1 2 5 6 7 Too manyelements Department of Computer Science — University of San Francisco – p.14/
Department of Computer Science — University of San Francisco – p.16/
When we split the root: Create a new root Tree grows in height by 1 Department of Computer Science — University of San Francisco – p.17/
Inserting elements 1-9 (in order) into a 2-3 tree 1 2 Department of Computer Science — University of San Francisco – p.19/
Inserting elements 1-9 (in order) into a 2-3 tree
Department of Computer Science — University of San Francisco – p.20/