Week 12 - Wednesday.  What did we talk about last time?  Matching  Stable marriage  Started Euler paths.

Slides:



Advertisements
Similar presentations
The 7 Bridges of Konigsberg A puzzle in need of solving.
Advertisements

Advanced Database Discussion B Trees. Motivation for B-Trees So far we have assumed that we can store an entire data structure in main memory What if.
B+-Trees (PART 1) What is a B+ tree? Why B+ trees? Searching a B+ tree
CS 206 Introduction to Computer Science II 04 / 27 / 2009 Instructor: Michael Eckmann.
COMP 451/651 Indexes Chapter 1.
Great Theoretical Ideas in Computer Science.
CSE332: Data Abstractions Lecture 9: BTrees Tyler Robison Summer
CS 206 Introduction to Computer Science II 12 / 05 / 2008 Instructor: Michael Eckmann.
CPSC 231 B-Trees (D.H.)1 LEARNING OBJECTIVES Problems with simple indexing. Multilevel indexing: B-Tree. –B-Tree creation: insertion and deletion of nodes.
CS 206 Introduction to Computer Science II 12 / 03 / 2008 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 12 / 01 / 2008 Instructor: Michael Eckmann.
B + -Trees (Part 1) Lecture 20 COMP171 Fall 2006.
B + -Trees (Part 1). Motivation AVL tree with N nodes is an excellent data structure for searching, indexing, etc. –The Big-Oh analysis shows most operations.
Tirgul 6 B-Trees – Another kind of balanced trees Problem set 1 - some solutions.
B + -Trees (Part 1) COMP171. Slide 2 Main and secondary memories  Secondary storage device is much, much slower than the main RAM  Pages and blocks.
B-Trees Chapter 9. Limitations of binary search Though faster than sequential search, binary search still requires an unacceptable number of accesses.
General Trees and Variants CPSC 335. General Trees and transformation to binary trees B-tree variants: B*, B+, prefix B+ 2-4, Horizontal-vertical, Red-black.
Balanced Trees. Binary Search tree with a balance condition Why? For every node in the tree, the height of its left and right subtrees must differ by.
B + -Trees COMP171 Fall AVL Trees / Slide 2 Dictionary for Secondary storage * The AVL tree is an excellent dictionary structure when the entire.
CPSC 335 BTrees Dr. Marina Gavrilova Computer Science University of Calgary Canada.
Indexing. Goals: Store large files Support multiple search keys Support efficient insert, delete, and range queries.
IntroductionIntroduction  Definition of B-trees  Properties  Specialization  Examples  2-3 trees  Insertion of B-tree  Remove items from B-tree.
B-Tree. B-Trees a specialized multi-way tree designed especially for use on disk In a B-tree each node may contain a large number of keys. The number.
ICS 220 – Data Structures and Algorithms Week 7 Dr. Ken Cosh.
Different Tree Data Structures for Different Problems
More Trees Multiway Trees and 2-4 Trees. Motivation of Multi-way Trees Main memory vs. disk ◦ Assumptions so far: ◦ We have assumed that we can store.
ALGORITHMS FOR ISNE DR. KENNETH COSH WEEK 6.
1 B Trees - Motivation Recall our discussion on AVL-trees –The maximum height of an AVL-tree with n-nodes is log 2 (n) since the branching factor (degree,
CSE AU B-Trees1 B-Trees CSE 373 Data Structures.
Multi-way Trees. M-way trees So far we have discussed binary trees only. In this lecture, we go over another type of tree called m- way trees or trees.
B-Trees. CSM B-Trees 2 Motivation for B-Trees So far we have assumed that we can store an entire data structure in main memory What if we have so.
INTRODUCTION TO MULTIWAY TREES P INTRO - Binary Trees are useful for quick retrieval of items stored in the tree (using linked list) - often,
Announcements Exam Friday. More Physical Storage Lecture 10.
Data Structures Balanced Trees 1CSCI Outline  Balanced Search Trees 2-3 Trees Trees Red-Black Trees 2CSCI 3110.
12.1 Chapter 12: Indexing and Hashing Spring 2009 Sections , , Problems , 12.7, 12.8, 12.13, 12.15,
B + -Trees. Motivation An AVL tree with N nodes is an excellent data structure for searching, indexing, etc. The Big-Oh analysis shows that most operations.
B-Trees. Motivation for B-Trees So far we have assumed that we can store an entire data structure in main memory What if we have so much data that it.
Starting at Binary Trees
1 Tree Indexing (1) Linear index is poor for insertion/deletion. Tree index can efficiently support all desired operations: –Insert/delete –Multiple search.
Week 11 - Monday.  What did we talk about last time?  Binomial theorem and Pascal's triangle  Conditional probability  Bayes’ theorem.
File Organization and Processing Week Tree Tree.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture17.
Indexing and hashing Azita Keshmiri CS 157B. Basic concept An index for a file in a database system works the same way as the index in text book. For.
CS 206 Introduction to Computer Science II 04 / 22 / 2009 Instructor: Michael Eckmann.
Lecture 11COMPSCI.220.FS.T Balancing an AVLTree Two mirror-symmetric pairs of cases to rebalance the tree if after the insertion of a new key to.
Week 8 - Wednesday.  What did we talk about last time?  Level order traversal  BST delete  2-3 trees.
Chapter 7 Trees_Part3 1 SEARCH TREE. Search Trees 2  Two standard search trees:  Binary Search Trees (non-balanced) All items in left sub-tree are less.
Week 12 - Monday.  What did we talk about last time?  Topological sort and cycle detection in directed graphs  Connectivity  Strong connectivity.
1 Multi-Level Indexing and B-Trees. 2 Statement of the Problem When indexes grow too large they have to be stored on secondary storage. However, there.
Week 10 - Friday.  What did we talk about last time?  Graph representations  Adjacency matrix  Adjacency lists  Depth first search.
B-TREE. Motivation for B-Trees So far we have assumed that we can store an entire data structure in main memory What if we have so much data that it won’t.
Week 13 - Monday.  What did we talk about last time?  B-trees  Hamiltonian tour  Traveling Salesman Problem.
Internal and External Sorting External Searching
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
Week 15 – Friday.  What did we talk about last time?  Student questions  Review up to Exam 2  Recursion  Binary trees  Heaps  Tries  B-trees.
Week 7 - Wednesday.  What did we talk about last time?  Recursive running time  Master Theorem  Symbol tables.
8/3/2007CMSC 341 BTrees1 CMSC 341 B- Trees D. Frey with apologies to Tom Anastasio.
Week 10 - Wednesday.  What did we talk about last time?  Counting practice  Pigeonhole principle.
Week 7 - Monday CS 113.
Week 10 - Monday CS 113.
Multiway Search Trees Data may not fit into main memory
B-Trees .
B+-Trees.
Week 15 – Friday CS221.
B+-Trees.
B+-Trees.
Week 11 - Monday CS221.
COP3530- Data Structures B Trees
Genome Assembly.
Week 10 - Wednesday CS221.
Presentation transcript:

Week 12 - Wednesday

 What did we talk about last time?  Matching  Stable marriage  Started Euler paths

 By simplifying the problem into a graph, the important features are clear  To arrive as many times as you leave, the degrees of each node must be even (except for the starting and ending points) Center Island North Shore East Island South Shore

 There is actually an way to find such a path on a graph where one exists:  Start with a node of odd degree if there is one  Every time we move across an edge, delete it  If you have a choice, always pick an edge whose deletion will not disconnect the graph  At the end of the algorithm, you will either have an Eulerian path or an Eulerian cycle, depending on the graph

 We can label the nodes to make a more interesting problem  Now each piece of land is associated with the Blue Prince, the Red Prince, the Bishop, or the Tavern

 The Blue Prince wants to build an 8th bridge so that he can walk starting at his castle, cross every bridge once, and end at the Tavern to brag

 Put the bridge from the Bishop’s land to the Red Prince’s land

 Furious, the Red Prince wants to build his own bridge so that only he can start at his own castle, cross all the bridges once and then end at the Tavern

 Put the bridge from the Red Prince’s land to the Blue Prince’s land

 Upset by this pettiness, the Bishop decides to build a 10th bridge which allows all citizens to cross all bridges and return to their starting point

 Put the bridge from the Center Island to the Red Prince’s land, making all pieces of land have even degree

Student Lecture

 Binary trees are great  However, only two splits means that you have a height of log 2 n when you want to store n things  If n = 1,000,000, log 2 n = 20  What if depth was expensive? Could we have say, 10 splits?  If n = 1,000,000, log 10 n = 6

 Answer: When the tree is in secondary storage  Each read of a block from disk storage is slow  We want to get a whole node at once  Each node will give us information about lots of child nodes  We don’t have to make many decisions to get to the node we want

 A B-tree of order m has the following properties: 1. The root has at least two subtrees unless it is a leaf 2. Each nonroot and each nonleaf node holds k keys and k + 1 pointers to subtrees where m/2 ≤ k ≤ m 3. Each leaf node holds k keys where m/2 ≤ k ≤ m 4. All leaves are on the same level

Insert

Insert

 Insert the following numbers: 

 When the list of keys drops below half m, we have to redistribute keys  In the worst case, we have to delete a level

 Instead of requiring every non-root node to be half full, every non-root node must be at least 2/3 full  Key redistribution becomes more complex  However, the tree is fuller

 Essentially, make a B-tree such that all the leaves are tied together in a linked list  It is also necessary that all keys in a B-tree appear as leaves  Some other variations are possible, but we’ll end the list here

Are you ready to get Hamiltonian with it?

 The Eulerian Cycle problem asked if you could start at some node, cross every edge once, and return to the start  The Hamiltonian Cycle problem asks if you can start at some node, visit every node only once, and return to the start  In other words, find a tour  Sounds easy, right?

 On this graph: E E A A C C B B D D E A C B D

 Now, on this graph:  There isn’t one! E E A A C C B B D D F F

 Now, on this graph: Hmmm…

 Given a graph, find the shortest tour that visits every node and comes back to the starting point  Like a lazy traveling salesman who wants to visit all possible clients and then return to his home

 Find the shortest TSP tour:  Starts anywhere  Visits all nodes  Has the shortest length of such a tour E E A A D D B B F F C C

 Strategies:  Always add the nearest neighbor  Randomized approaches  Try every possible combination  Why are we only listing strategies?

 So far we haven’t given a foolproof solution to TSP  Let’s look at two possibilities:  Greedy Solution: Pick the closest neighbor  Brute Force: Try all possibilities

 Finish NP-completeness  Elementary sorts  Merge sort

 Start on Project 4  Form teams by Friday  Start on Assignment 6  Read sections 2.1 and 2.2