optimal solution minimizing number of $3’s has at most one $3 ($3 + $3  $5 + $1) has at most two $1’s ($1+$1+$1  $3) has value at most $4 in $1 and.

Slides:



Advertisements
Similar presentations
Greedy Algorithms Amihood Amir Bar-Ilan University.
Advertisements

Data Structures Haim Kaplan and Uri Zwick November 2012 Lecture 5 B-Trees.
Data Abstraction and Problem Solving with JAVA Walls and Mirrors Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Data Abstraction and Problem.
CSE332: Data Abstractions Lecture 9: B Trees Dan Grossman Spring 2010.
B-Trees. Motivation for B-Trees Index structures for large datasets cannot be stored in main memory Storing it on disk requires different approach to.
1 B trees Nodes have more than 2 children Each internal node has between k and 2k children and between k-1 and 2k-1 keys A leaf has between k-1 and 2k-1.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter Trees and B-Trees.
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.
B + -Trees Same structure as B-trees. Dictionary pairs are in leaves only. Leaves form a doubly-linked list. Remaining nodes have following structure:
B-Tree B-Tree is an m-way search tree with the following properties:
CS 206 Introduction to Computer Science II 12 / 01 / 2008 Instructor: Michael Eckmann.
B + -Trees (Part 1) Lecture 20 COMP171 Fall 2006.
1 Database indices Database Systems manage very large amounts of data. –Examples: student database for NWU Social Security database To facilitate queries,
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.
CSE 326: Data Structures B-Trees Ben Lerner Summer 2007.
B+ - Tree & B - Tree By Phi Thong Ho.
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.
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, that is) Steve Wolfman 2014W1
B + -Trees COMP171 Fall AVL Trees / Slide 2 Dictionary for Secondary storage * The AVL tree is an excellent dictionary structure when the entire.
1 Section 9.2 Tree Applications. 2 Binary Search Trees Goal is implementation of an efficient searching algorithm Binary Search Tree: –binary tree in.
File Structures Dale-Marie Wilson, Ph.D.. Basic Concepts Primary storage Main memory Inappropriate for storing database Volatile Secondary storage Physical.
Index Structures Parin Shah Id:-207. Topics Introduction Structure of B-tree Features of B-tree Applications of B-trees Insertion into B-tree Deletion.
Tirgul 6 B-Trees – Another kind of balanced trees.
Splay Trees and B-Trees
1 B-Trees Section AVL (Adelson-Velskii and Landis) Trees AVL tree is binary search tree with balance condition –To ensure depth of the tree is.
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 What is a B+ Tree Searching Insertion Deletion.
 B+ Tree Definition  B+ Tree Properties  B+ Tree Searching  B+ Tree Insertion  B+ Tree Deletion.
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.
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.
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.
B + TREE. INTRODUCTION A B+ tree is a balanced tree in which every path from the root of the tree to a leaf is of the same length, and each non leaf node.
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,
CSE373: Data Structures & Algorithms Lecture 15: B-Trees Linda Shapiro Winter 2015.
1 CPS216: Advanced Database Systems Notes 04: Operators for Data Access Shivnath Babu.
Trevor Brown – University of Toronto B-slack trees: Space efficient B-trees.
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.
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.
AVL Tree Definition: Theorem (Adel'son-Vel'skii and Landis 1962):
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.
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.
CSED101 INTRODUCTION TO COMPUTING TREE 2 Hwanjo Yu.
Succinct Dynamic Cardinal Trees with Constant Time Operations for Small Alphabet Pooya Davoodi Aarhus University May 24, 2011 S. Srinivasa Rao Seoul National.
Search Trees: BSTs and B-Trees David Kauchak cs161 Summer 2009.
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.
Data Structures and Algorithms (AT70.02) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor: Prof. Sumanta Guha Slide Sources: CLRS “Intro.
October 19, 2005Copyright © by Erik D. Demaine and Charles E. LeisersonL7.1 Introduction to Algorithms LECTURE 8 Balanced Search Trees ‧ Binary.
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.
Internal and External Sorting External Searching
Lecture 10COMPSCI.220.FS.T Binary Search Tree BST converts a static binary search into a dynamic binary search allowing to efficiently insert and.
B-Trees Katherine Gurdziel 252a-ba. Outline What are b-trees? How does the algorithm work? –Insertion –Deletion Complexity What are b-trees used for?
More Trees. Outline Tree B-Tree 2-3 Tree Tree Red-Black Tree.
B+-Tree Deletion Underflow conditions B+ tree Deletion Algorithm
ITEC 2620M Introduction to Data Structures Instructor: Prof. Z. Yang Course Website: ec2620m.htm Office: TEL 3049.
CSE 326: Data Structures Lecture #9 Big, Bad B-Trees Steve Wolfman Winter Quarter 2000.
Data Structures and Algorithms
Introduction Applications Balance Factor Rotations Deletion Example
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
CS200: Algorithms Analysis
COP3530- Data Structures B Trees
BTrees.
B-Tree.
The algorithm of Garsia and Wachs
Solution for Section Worksheet 4, #7b & #7c
Presentation transcript:

optimal solution minimizing number of $3’s has at most one $3 ($3 + $3  $5 + $1) has at most two $1’s ($1+$1+$1  $3) has value at most $4 in $1 and $3  has the same number of $5 as greedy sol yes

no 8 = =

yes optimal solution minimizing number of $4’s has at most one $4 ($4 + $4  $7 + $1) has at most three $1’s ($1+$1+$1+$1  $4) has value at most $6 in $1 and $4  has the same number of $7 as greedy sol

MAIN IDEA: if there is a counterexample then there is a small counterexample 1<A<B

LEMMA: optimal solution for the smallest counterexample doesn’t contain B E = O 1 + O A * A + O B * B E = G 1 + G A * A + G B * B E-B = O 1 + O A * A + (O B -1)*B E-B = G 1 + G A * A + (G B -1)*B

LEMMA: optimal solution for the smallest counterexample doesn’t contain B copies of A (A+A+...+A  B+B+...+B) A copies of 1 (  A) E  (B-1)*A + (A-1) = A*B-1

THEOREM: if there is a counterexample then there is on with E  A*B-1 MAIN IDEA: if there is a counterexample then there is a small counterexample

for all C  AB-1 find optimum (dynamic programming) check if agrees with greedy

LEMMA: greedy solution for the smallest counterexample doesn’t contain A E = O 1 + O A * A E = G 1 + G A * A + G B * B E-A = O 1 + (O A -1)* A E-A = G 1 + (G A -1)* A + G B *B

LEMMA: optimal solution for the smallest counterexample doesn’t contain 1 E = O 1 + O A * A E = G 1 + G B * B E-1 = (O 1 -1)+ O A * A E-1 = (G 1 -1)+ + G B * B

LEMMA: If there exists a counterexample, then there exists a counterexample E = O A * A E = G 1 + G B * B with O A <B and G 1 <A

LEMMA: If there exists a counterexample, then there exists a counterexample E = O A * A E = G 1 + G B * B with O A <B and G 1 <A with G B = 1

polynomial-time solution  check if P=  B/A  A is a counterexample 

 check if P=  B/A  A is a counterexample 6 = = 2*3 yes 8 = = 2*4 no 8 = 7 +1 = 2*4 yes

each measurement has 3 outcomes 3 measurements  27 outcomes N=14  2*14 = 28 outcomes

SG S SGG 1/3 2/3

M[i,j] = min { P[j] + min M[k,j] + M[i-k,j] P[i] + min M[i,k] + M[i,j-k] 1  k  i-1 1  k  j-1

K[i,s]  K[i-1,s] if s  W[i] and K[i-1,s-W[i]]+V[i]>K[i,s] then K[i,s]  K[i-1,s-W[i]]+V[i]

M(m,n)=m * n - 1 proof: induction on m+n base case m+n=2  m=n=1 ok m * n  m 1 * n and m 2 * n, by IH (m 1 *n – 1) + (m 2 * n – 1 ) + 1 = m * n -1

binary search tree depth  running time INSERT DELETE SEARCH

B-tree branching factor > 2 * makes balancing easier * efficient for “burst memory” (HDD) uniform depth INSERT DELETE SEARCH

B-tree branching factor > 2 * makes balancing easier * efficient for “burst memory” (HDD)

B-tree every node other than the root has  T-1 keys (i.e.,  T children) every node has  2T-1 keys (i.e.,  2T children) if T=2 the number of children is 2,3, or 4

B-tree - insert INSERT(T,26)

B-tree - insert INSERT(T,26)

B-tree - insert INSERT(T,26)

B-tree - insert INSERT(T,26) 27

B-tree - insert INSERT(T,28) 27 full leaf

B-tree - insert INSERT(T,28) 27 full leaf

B-tree - insert INSERT(T,28) 27 full leaf

B-tree - insert INSERT(T,28) 27 full leaf

B-tree - insert INSERT(T,28) 27 full leaf

B-tree - insert INSERT(T,28) 27 full leaf

B-tree - insert INSERT(T,28) 27 full leaf 28

B-tree - insert INSERT(T,26) split proactively

B-tree - insert INSERT(T,26) split proactively

B-tree - insert INSERT(T,26) split proactively

B-tree - insert INSERT(T,26) split proactively

B-tree - insert INSERT(T,26) split proactively

B-tree - insert INSERT(T,26) split proactively 2627

B-tree - insert INSERT(T,28) split proactively 2627

B-tree - insert INSERT(T,28) split proactively

B-tree - insert 2T-1 keys  T-1 and T-1 keys every node other than the root has  T-1 keys (i.e.,  T children) every node has  2T-1 keys (i.e.,  2T children) uniform depth – the only operation increasing depth is splitting the root

B-tree - delete DELETE(T,28)

B-tree - delete DELETE(T,28) leaf deletion

B-tree - delete DELETE(T,27) leaf deletion ?