CSE 214 – Computer Science II B-Trees

Slides:



Advertisements
Similar presentations
Heaps and heapsort COMP171 Fall Sorting III / Slide 2 Motivating Example 3 jobs have been submitted to a printer in the order A, B, C. Sizes: Job.
Advertisements

A Binary Tree root leaf. A Binary Tree root leaf descendent of root parent of leaf.
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 19: B-Trees: Data Structures for Disk.
CS 206 Introduction to Computer Science II 12 / 03 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 10 / 29 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 12 / 01 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 04 / 29 / 2009 Instructor: Michael Eckmann.
Binary Trees Chapter 6.
Lecture 06: Tree Structures Topics: Trees in general Binary Search Trees Application: Huffman Coding Other types of Trees.
B-trees (Balanced Trees) A B-tree is a special kind of tree, similar to a binary tree. However, It is not a binary search tree. It is not a binary tree.
Storage CMSC 461 Michael Wilson. Database storage  At some point, database information must be stored in some format  It’d be impossible to store hundreds.
P p Chapter 10 has several programming projects, including a project that uses heaps. p p This presentation shows you what a heap is, and demonstrates.
CSE 250 September 29 – October 3, A NNOUNCEMENTS Homework 4 due 10/5 Project 1 posted for 10/6 Exam 2 10/8 No classes meet 10/9 Project 1 due 10/26.
CS 206 Introduction to Computer Science II 04 / 22 / 2009 Instructor: Michael Eckmann.
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
CPSC 252 Binary Heaps Page 1 Binary Heaps A complete binary tree is a binary tree that satisfies the following properties: - every level, except possibly.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
CS422 Principles of Database Systems Indexes
Final Exam Review COP4530.
Final Exam Review CS 3358.
CSE373: Data Structures & Algorithms Priority Queues
Partially Ordered Data ,Heap,Binary Heap
Data Structures Interview Questions.
COMP261 Lecture 23 B Trees.
CSE 214 – Computer Science II Binary Trees
Data Structures and Algorithms for Information Processing
Heaps (8.3) CSE 2011 Winter May 2018.
Multiway Search Trees Data may not fit into main memory
CS522 Advanced database Systems
CSC212 Data Structure - Section AB
Indexing ? Why ? Need to locate the actual records on disk without having to read the entire table into memory.
Data Structures Binary Trees 1.
Lecture 15 AVL Trees Slides modified from © 2010 Goodrich, Tamassia & by Prof. Naveen Garg’s Lectures.
Heapsort CSE 373 Data Structures.
B+ Trees What are B+ Trees used for What is a B Tree What is a B+ Tree
Binary Search Tree Chapter 10.
Lecture 22 Binary Search Trees Chapter 10 of textbook
B+ Tree.
Week 11 - Friday CS221.
Hashing Exercises.
Source: Muangsin / Weiss
Cse 373 April 26th – Exam Review.
Tonga Institute of Higher Education
i206: Lecture 13: Recursion, continued Trees
Binary Search Trees Why this is a useful data structure. Terminology
original list {67, 33,49, 21, 25, 94} pass { } {67 94}
Trees and Binary Trees.
CMSC 341: Data Structures Priority Queues – Binary Heaps
CS200: Algorithm Analysis
B+ Trees What are B+ Trees used for What is a B Tree What is a B+ Tree
Balanced-Trees This presentation shows you the potential problem of unbalanced tree and show two way to fix it This lecture introduces heaps, which are.
Final Exam Review COP4530.
B-Tree.
B-Trees This presentation shows you the potential problem of unbalanced tree and show one way to fix it This lecture introduces heaps, which are used.
Priority Queues (Chapter 6.6):
Balanced-Trees This presentation shows you the potential problem of unbalanced tree and show two way to fix it This lecture introduces heaps, which are.
A Robust Data Structure
Searching CLRS, Sections 9.1 – 9.3.
2-3-4 Trees Red-Black Trees
CSE 332: Data Structures Priority Queues – Binary Heaps Part II
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Heapsort CSE 373 Data Structures.
Topic 6: Binary Search Tree Data structure Operations
Topic 5: Heap data structure heap sort Priority queue
Definition Applications Implementations Heap Comparison
CSE 373, Copyright S. Tanimoto, 2002 Priority Queues -
Priority Queues (Chapter 6):
B-Trees.
B-Trees This presentation shows you the potential problem of unbalanced tree and show one way to fix it This lecture introduces heaps, which are used.
CMPT 225 Lecture 16 – Heap Sort.
Presentation transcript:

CSE 214 – Computer Science II B-Trees Source: http://paulmirocha.com/resources/images/sketchbook/beetreecover.jpg

Coding Exam 3 Friday, 12/4 – Starting at 2:15 Topics: Stacks (using linked lists & arrays) Queues (using linked lists & arrays) Hash Tables (open address & chained) Heaps Sample exam is posted to schedule page note, past exams have not covered identical topics sample exam only has stacks & queues

Exam Review Session Thursday, 8 – 9:30 pm CS 2129

We’ve studied many types of trees already Binary Search Trees K-ary Trees Complete Trees Full Trees Octrees

There are many, many, more B-Trees Red-Black trees 2-3 Trees Etc. There are custom trees for solving many problems

Let’s examine on such tree: B-Trees There will be final exam questions on B-Trees conceptual only Note: this is perhaps the toughest topic we’ll cover this semester Why is it tough? complexity of implementation at first glance, benefits aren’t obvious Why are we covering it? they are an important technology (DBMSs love them)

B-Tree applications Foundation for database and file system data management Why are they used? O(log N) amortized time for accessing, insertion, deletion What’s amortized time? average time per calculation measure over a large number of operations

A B-Tree with Letters for data What characteristics do you notice about this B-Tree? it’s sorted, each node has multiple data points, nodes may have many children, the number of children is related to the amount of data a node has, all leaves are on the same level Ref: http://cis.stvincent.edu/html/tutorials/swd/btree/btree1.gif

The 6 B-Tree Rules The root can have as few as one element (or no elements if it has no children). Every other node has at least MINIMUM elements. The MAXIMUM number of elements in a node is twice the value of MINIMUM. The elements of each B-Tree node are stored in a partially filled array, sorted from the smallest element (at index 0) to the largest element (at the final used position of the array). The number of sub-trees below a non-leaf node is always one more than the number of elements in the node For any non-leaf node: (a) An element at index i is greater than the elements in sub-tree number i of the node, and (b) an element at index i is less than all the elements in sub-tree number i + 1 of the node. Every leaf in a B-tree has the same depth

A note about MAXIMUM & MINIMUM These values are selected through tuning What’s tuning? examining performance at runtime making appropriate changes to optimize MINIMUM selected based on: amount of data for the B-Tree likely operations to perform on tree may be in hundreds or thousands in a database Selecting MINIMUM affects: size of nodes depth of tree efficiency of various operations

The 6 B-Tree Rules The root can have as few as one element (or no elements if it has no children). Every other node has at least MINIMUM elements.

The 6 B-Tree Rules 2. The maximum number of elements in a node is twice the value of MINIMUM.

The 6 B-Tree Rules 3. The elements of each B-Tree node are stored in a partially filled array, sorted from the smallest element (at index 0) to the largest element (at the final used position of the array).

The 6 B-Tree Rules 4. The number of sub-trees below a non-leaf node is always one more than the number of elements in the node

The 6 B-Tree Rules 5. For any non-leaf node: (a) An element at index i is greater than all the elements in sub-tree number i of the node, and (b) an element at index i is less than all the elements in sub-tree number i + 1 of the node.

The 6 B-Tree Rules 6. Every leaf in a B-tree has the same depth

What would each node need? an array of data counter for data array of child nodes counter for children What should our B-Tree’s data be? any sortable object we can specify our own comparison criteria