CSE 4500 (228) Fall 2010 Selected Notes Set 2
|
|
- Abraham Carpenter
- 5 years ago
- Views:
Transcription
1 CSE 4500 (228) Fall 2010 Selected Notes Set 2 Alexander A. Shvartsman Computer Science and Engineering University of Connecticut Copyright c by Alexander A. Shvartsman. All rights reserved.
2 2 Basic Algorithms: Parallel Tree Traversals HERE we present basic techniques where parallel processors operate in synchrony on binary trees stored in shared memory. We include code examples for enumerating processors and load balancing. The algorithms use full binary trees for purposes of accumulation and utilization of global knowledge about the computation. 2.1 Storing and Traversing Trees It is often desirable for trees used in parallel algorithms to not require explicit construction any maintenance of their topology. This is easily accomplished by storing a tree in an array with implicit tree structure as follows (Figure 2.2). tree[0... 6] Figure 2.2: Storing a maintenance-free binary tree in an array. A complete binary tree with n leaves is represented as the linear array tree[0... 2n 2]. The root of the tree is the first element of the array, tree[0]. Any non-leaf element tree[i] has the element tree[2i + 1] as its left child and the element tree[2i + 2] as its right child 1. When the number of leaves is not a power of two, conventional padding techniques can be used. Commonly algorithms use either the bottom-up or top-down traversal of such full binary trees. The number of leaves is normally equal to, or propor- 1 Equivalently, one can use a linear array tree[1... 2n 1], in which case the root of the tree is the first element of the array, tree[1], and any non-leaf element tree[i] has the element tree[2i] as its left child and the element tree[2i + 1] as its right child. 1
3 CSE 4500 (228) Fall 2010 Set 2, Page 2 Bottom-up parallel traversal of full binary trees: Computes or updates sums of values stored at the leaves O(log N) time O(P log N) work (or cost) Examples of use: processor enumeration, progress evaluation Top-down parallel traversal of full binary trees: Divide-and-conquer according to the hierarchy specified by the tree O(log N) time O(P log N) work (or cost) Examples of use: processor allocation and load balancing log N N log N N Figure 2.3: Synchronous bottom-up and top-down tree traversals. tional to the size of the input to the algorithm, say N. The height of the tree is logarithmic in N (assuming the degree of the tree is a constant). The bottom-up traversals can be easily used to implement, for example, a parallel summation algorithm, and the top-down traversal implement a divide-and-conquer processor allocation strategy using a hierarchy, see Figure 2.3. The traversals take logarithmic time. This tree scheme is readily generalized to trees other than binary. For example, for ternary trees, a non-leaf element i has three children whose indices are 3i + 1, 3i + 2, and 3i + 3 respectively. For q-ary trees, a non-leaf element i has q children whose indices are qi + 1, qi + 2,..., qi + q. The binary trees that we illustrate below be generalized to logarithmic (base q) time traversals of full q-ary trees for some constant q. For most simple algorithms the best performance is achieved with binary trees, but there are algorithms using trees that can be parameterized so that the desired performance bounds are achieved when the trees are not binary. Now we give a few intuition-building examples. The detailed code is given later in this chapter. First we give an illustration of the use of top-down traversal to count the number of active processors. This estimate is taken to be the number of active processors who may have reached the root of the tree:
4 CSE 4500 (228) Fall 2010 Set 2, Page 3 Example Processor counting: Consider a processor counting tree with N = 4 leaves. The tree is stored in the array c[0..6], initialized to 0. There are four processors with PIDs 1, 2, 3, and 4, that start at the leaves and traverse the tree towards its root. At each step, a processor writes into the node corresponding to its location in the tree, the sum of the two child locations. c[0] : c[1, 2] : c[3, 4, 5, 6] : PID: If processors with PIDs 2, 3 and 4 participate, then the root c[0] has the value 3. Note that processor 1 did not need to participate to obtain the correct result. The following example illustrates the use of a tree, called the progress tree, that is often used in the divide-and-conquer processor allocation. We assume that each leaf is associated with a task that needs to be performed by the processors. Here we evaluate the number of completed tasks based on the information brought to the root of the tree by the processors participating in the computation: Example Progress evaluation: Consider the progress tree with four leaves (N = 4) stored in the array d[0..6]. There are 4 processors with PIDs 1, 2, 3, and 4, that begin at the leaves and traverse the tree towards the root. Each processor begins by writing into its leaf an indication (value 1) that it finished its task; if a processor did not complete its task the leaf remains untouched (value 0). The processors move towards the root of the tree one level at a time, and store in each parent the sum of its children. If processors 1 and 2 finished their tasks, but 3 and 4 did not, then the tree d will look like this after the completion of the algorithm. d[0] : d[1, 2] : d[3, 4, 5, 6] : PID: Note that the value of the root d[0] is 2. This indicates that not all tasks were completed, since d[0] = 2 < 4 = N.
5 CSE 4500 (228) Fall 2010 Set 2, Page 4 In the load balancing top-down traversal, we assume that the progress tree is an exact summation tree (i.e, the value at each internal node is the sum of the values at its two children), and the processors are allocated at each non-leaf node of the tree in proportion to the number of remaining tasks in each subtree. Example Load balancing: Consider the progress tree with four leaves (N = 4) stored in the array a[0..6]. There are two active processors with PIDs 1 and 2, that begin at the root and traverse the tree towards the leaves. PID: a[0] : a[1, 2] : a[3, 4, 5, 6] : {1, 2} In this example, starting at the root, both processors will be sent to the right subtree. This is because out of the two tasks in the left subtree, both have been completed, and none of the tasks in the right subtree are completed. At the internal node a[2], the two processors will be equally divided between the left (a[5]) and the right (a[6]) subtrees, since equal number of unfinished tasks exists in each of the two subtrees. Note that the progress-assessment traversal in Example is guaranteed to yield the exact summation tree needed by the load balancing traversal in Example above. Algorithms that do not assume that the progress tree is a summation tree must be able to deal with such situations. (We used synchronous tree traversals in the examples. Some traversals of such progress trees can also be used when processors do so without synchronizing with each other.) 2.2 Processor Enumeration We now give three algorithms designed to enumerate the participating processors. These algorithms use an approach similar to the parallel-prefix computation. Each algorithm uses auxiliary tree data structures. The algorithms differ in their assumptions about the initial values at tree nodes. The first algorithm is the simplest: it assumes clear shared memory, that is, all nodes of the tree are intialized to zeros. The second algorithm uses time-stamps to ensure that the values in the data structure are fresh. It is somewhat more complicated we present it to illustrate the time-stamping technique.
6 CSE 4500 (228) Fall 2010 Set 2, Page 5 The third algorithm clears the needed memory before using it. Each algorithm is presented as a procedure that can be called by the processors from the high-level program that is specified for all processors, e.g., forall processors pid = 1..P parbegin Enumerate(...) parend Enumeration: using clear memory The enumeration is done using a bottom-up traversal of the tree c to compute the number of active processors in c[0]. Each processor computes its enumerated number in pn. The code is in Figure 2.4. Each processor PID starts by writing a 1 in the leaf c[pid+n 2] of the tree c. If a processor is inactive then its leaf will contain 0 and this will not contribute to the overall count. procedure Enumerate1( - - Processor enumeration integer pid, - - processor id integer pn) - - enumerated id shared integer c[0..2n 2] init 0, - - processor counts: clear memory private integer j1, j2, - - sibling indices: left or right t; - - parent of j1 and j2 begin j1 := pid + (N 2); - - tree-leaf init pn := 1; - - assume this PID is no. 1 c[j1] := 1; - - count PID once - - Traverse the tree from leaf to root for 1... log(n) do t := (j1 1) div 2; - - parent of j1 and j2 if 2 t + 1 = j1 - - j1 came from... then j2 := j left subtree else j2 := j right subtree fi c[t] := c[j1] + c[j2] - - compute sum if j1 > j2 - - j1 came from right then pn := pn + c[j2] fi j1 := t - - advance up the tree rof end. Figure 2.4: Enumeration using clear memory We enumerate the active processors by each processor assuming that it is the only active one, and then adding the number of the active processors it
7 CSE 4500 (228) Fall 2010 Set 2, Page 6 sees to its left. This is a variation of the parallel prefix computation. This enumeration creates the dynamic processor number pn Enumeration: using time-stamps This is essentially the same algorithm, but it introduces the use of time-stamps. The tree cs is used to ensure that only the recent values are used when the algorithm is used multiple times. The code is in Figure 2.5. procedure Enumerate2( - - Processor enumeration integer pid, - - processor id integer step, - - time-stamp integer pn) - - enumerated id shared integer c[0..2n 2], - - processor counts cs[0..2n 2]; - - associated time-stampts step init time-stamp private integer j1, j2, - - sibling indices t; - - parent of j1 and j2 begin step := step + 1; - - new time-stamp j1 := pid + (N 2); - - tree-leaf init pn := 1; - - assume this PID is no. 1 c[j1] := 1; - - count PID once cs[j1] := step; - - update time-stamp - - Traverse the tree from leaf to root for 1... log(n) do t := (j1 1) div 2; - - parent of j1 and j2 if 2 t + 1 = j1 - - j1 came from... then j2 := j left subtree else j2 := j1 1 fi - - right subtree if cs[j1] = cs[j2] - - active sibling? then c[t] := c[j1] + c[j2] - - yes, compute sum if j1 > j2 - - j1 came from right then pn := pn + c[j2] fi else c[t] := c[j1] - - no active siblings fi cs[t] := step; - - time stamp, and j1 := t - - advance up the tree rof end. Figure 2.5: Enumeration using time-stamps We must be able to reuse our tree during several uses of the enumeration algorithm For example, if a processor had written 1 into its tree leaf and then became inactive then, the value 1 will remain there for the duration of the com-
8 CSE 4500 (228) Fall 2010 Set 2, Page 7 putation, thus preventing us from accurately computing the number of active processors. This is corrected by associating a step number with each node of the count tree c and storing it in tree cs, thus time-stamping valid data. The count step is initially zero, and during each use of the algorithm it gets incremented by each active processor. The values written previously by inactive processors will have old step numbers, and active processors detect counts that are out-of-date and treat them as zeroes Enumeration: clearing old data In this similar algorithm each active processor assumes that there are no active siblings at any tree node. This is done by clearing the sibling s value in the tree c and then writing the new value in the processor s current location in c. The code is in Figure 2.6. procedure Enumerate3( - - Processor enumeration integer pid, - - processor id integer step, - - time-stamp integer pn) - - enumerated id shared integer c[1..2n 2], - - processor counts private integer st, - - running subtree subtotal j1, j2, - - sibling indices t; - - parent of j1 and j2 begin j1 := P ID + (N 2); - - tree-leaf init pn := 1; - - assume this PID is no. 1 st := 1; - - count PID once - - Traverse the tree from leaf to root for 1... log(n) do t := (j1 1) div 2; - - parent of j1 and j2 if 2 t + 1 = j1 - - j1 came from... then j2 := j left subtree else j2 := j1 1 fi - - right subtree c[j2] := 0; - - assume sibling(s) is inactive c[j1] := st; - - self is active if j1 > j2 - - j1 came from right then pn := pn + c[j2] fi st := c[j1] + c[j2]; - - update tree subtotal, and j1 := t - - advance up the tree rof end. Figure 2.6: Enumeration and clearing old data
9 CSE 4500 (228) Fall 2010 Set 2, Page Progress Assessment Processors execute this algorithm having completed (or not completed) their individual tasks at the time the coordination needs to take place. A processor that worked on task number k makes a call to procedure Progress(k, done), where done is the task completion status. The processors proceed in synchrony from leaf to root and build the progress tree d where each subtree root contains the number of completed tasks in its subtree. Note that if the progress tree is initialized to zeros then only the processors that completed their tasks need to participate. The resulting progress tree is a summation tree where each interior node is the sum of its two children. procedure Progress( integer k, - - Current processor s task index boolean done) - - Task completion: true/false shared integer array d[1..2n 1]; - - done/progress tree private integer i1, i2 - - left/right (or left/right) sibling indices t; - - parent of i1 and i2 - - Mark the leaf done/not done i1 := k + (N 1); - - progress tree leaf index if done then d[i1] := 1; - - done else d[i1] := 0; - - not done fi - - Traverse the tree from leaf to root for 1... log(n) do - - The parent index of i1 and i2 t := (i1 1) div Compute left/right indices if 2 t + 1 = i1 - - i1 came from... then i2 := i from left, i2 is on the right else i2 := i from right, i2 is on the left fi - - Update progress tree and advance d[t] := d[i1] + d[i2]; - - update i1 := t - - advance to the parent od end. Figure 2.7: Progress estimation building a divide-and-conquer hierarchy
10 CSE 4500 (228) Fall 2010 Set 2, Page Load balancing according to a hierarchy The load balancing algorithm uses a progress tree, such as the one built by procedure Progress(, ) in Figure 2.7. The processors traverse the tree from root to leaf and allocate themselves to the left/right subtree in proportion to the tasks the remain undone in each subtree. When a processor reaches a leaf it computes the index k of the task it is going to perform. The algorithm assumes that the available processors are sequentially numbered starting with 1. Each processor uses its enumerated processor number pn instead of its permanent PID. The enumerated numbers can be computed by any of the procedures in Figures 2.4, 2.5 or 2.6. procedure Divide-and-Conquer( integer pn, - - dynamic processor number integer P, - - dynamic processor number integer k) - - computed data (work item) index shared integer array c[0..2n 2], - - processor counts (does not need to be shared) d[0..2n 2]; - - progress/done tree private integer j, j1, j2; - - current/left/right indices j := 0; - - start at the root of the progress tree size := N; - - the whole tree is visible from the root (N is const.) c[0] := P ; - - the root of the processor tree is P - - Traverse from root to leaf while size 1 do j1 := 2 j + 1; j2 := 2 j + 2; - - left/right - - Processor allocation to left/right sub-trees c[j1] := c[j] (size/2 d[j1]) div (size d[j]); c[j2] := c[j] c[j1]; - - Go left/right based on proc. no. if pn c[j1] then j := j1 else j := j2; pn := pn c[j1] fi size := size div half of leaves for next iteration od ; k := j (N 1) - - assign to task k based on j end. Figure 2.8: Load balancing according to a hierarchy
11 CSE 4500 (228) Fall 2010 Set 2, Page Broadcast Using a Tree Now we consider a simple algorithm for CREW PRAM that allows one processor to broadcast its private value to all processors. The algorithm is given in Figure 2.9. For simplicity we assume that P = 2 k 1 for some integer k > 0, and that processor with pid = 1 needs to broadcast its private value. The broadcast is done according to the tree B[1..P ] (line 02). For this algorithm the root of the tree is the first element of the array, B[1], and any non-leaf element B[i] has the element B[2i] as its left child and the element B[2i + 1] as its right child. Therefore for any node B[j] of the tree, its parent is node B[j div 2]. The algorithm starts with processor 1 writing its value to the root of the tree (line 03). Then, for each of the log P remaining levels of the tree, the processors at level h read the values from their corresponding parents at level h 1 (lines 04-07). 01 forall processors pid = 1..P parbegin 02 shared B[1..P ] - - Broadcast tree, with one node per processor 03 if pid = 1 then B[1] := value fi - - Processor 1 writes its value to the root 04 for h = 1 to log P do - - For each level h of the broadcast tree 05 if 2 h pid < 2 h+1 then - - The processors at level h 06 B[pid] := B[pid div 2] - - Read parent s value 07 od 08 parend. Figure 2.9: Pseudocode for the CREW PRAM broadcast algorithm The algorithm takes Θ(log P ) time, and its work (or cost) is Θ(P log P ). Note that the algorithm above does require concurrent reads: two siblings read the value from the their parent concurrently when they pull the broadcast value from the parent. We next slightly modify this algorithm, so that each parent pushes its value to both children, allowing the algorithm to be executed on EREW PRAM. The algorithm is gven in Figure The algorithm uses the same broadcast tree B[1..P ] (line 02). The algorithm starts with processor 1 writing its value to the root of the tree (line 03). Then, for each of the log P remaining levels of the tree, starting with the root, the processors at level h write their value to both of its children at level h + 1 (lines 04-08). The complexity of the algorithm is unchanged.
12 CSE 4500 (228) Fall 2010 Set 2, Page forall processors pid = 1..P parbegin 02 shared B[1..P ] - - Broadcast tree, with one node per processor 03 if pid = 1 then B[1] := value fi - - Processor 1 writes its value to the root 04 for h = 0 to log P 1 do - - For each level h of the broadcast tree 05 if 2 h pid < 2 h+1 then - - The processors at level h 06 B[2pid] := B[pid] - - Push value to left child 07 B[2pid + 1] := B[pid] - - Push value to right child 07 od 09 parend. Figure 2.10: Pseudocode for the EREW PRAM broadcast algorithm
Multi-way Search Trees. (Multi-way Search Trees) Data Structures and Programming Spring / 25
Multi-way Search Trees (Multi-way Search Trees) Data Structures and Programming Spring 2017 1 / 25 Multi-way Search Trees Each internal node of a multi-way search tree T: has at least two children contains
More informationCSCI2100B Data Structures Trees
CSCI2100B Data Structures Trees Irwin King king@cse.cuhk.edu.hk http://www.cse.cuhk.edu.hk/~king Department of Computer Science & Engineering The Chinese University of Hong Kong Introduction General Tree
More informationChapter 11: Indexing and Hashing
Chapter 11: Indexing and Hashing Basic Concepts Ordered Indices B + -Tree Index Files B-Tree Index Files Static Hashing Dynamic Hashing Comparison of Ordered Indexing and Hashing Index Definition in SQL
More informationCSE 530A. B+ Trees. Washington University Fall 2013
CSE 530A B+ Trees Washington University Fall 2013 B Trees A B tree is an ordered (non-binary) tree where the internal nodes can have a varying number of child nodes (within some range) B Trees When a key
More informationTrees. Reading: Weiss, Chapter 4. Cpt S 223, Fall 2007 Copyright: Washington State University
Trees Reading: Weiss, Chapter 4 1 Generic Rooted Trees 2 Terms Node, Edge Internal node Root Leaf Child Sibling Descendant Ancestor 3 Tree Representations n-ary trees Each internal node can have at most
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 11: Binary Search Trees MOUNA KACEM mouna@cs.wisc.edu Fall 2018 General Overview of Data Structures 2 Introduction to trees 3 Tree: Important non-linear data structure
More informationCS 171: Introduction to Computer Science II. Binary Search Trees
CS 171: Introduction to Computer Science II Binary Search Trees Binary Search Trees Symbol table applications BST definitions and terminologies Search and insert Traversal Ordered operations Delete Symbol
More informationLaboratory Module Trees
Purpose: understand the notion of 2-3 trees to build, in C, a 2-3 tree 1 2-3 Trees 1.1 General Presentation Laboratory Module 7 2-3 Trees 2-3 Trees represent a the simplest type of multiway trees trees
More informationCS Fall 2010 B-trees Carola Wenk
CS 3343 -- Fall 2010 B-trees Carola Wenk 10/19/10 CS 3343 Analysis of Algorithms 1 External memory dictionary Task: Given a large amount of data that does not fit into main memory, process it into a dictionary
More informationTree Structures. A hierarchical data structure whose point of entry is the root node
Binary Trees 1 Tree Structures A tree is A hierarchical data structure whose point of entry is the root node This structure can be partitioned into disjoint subsets These subsets are themselves trees and
More informationB-Trees. Version of October 2, B-Trees Version of October 2, / 22
B-Trees Version of October 2, 2014 B-Trees Version of October 2, 2014 1 / 22 Motivation An AVL tree can be an excellent data structure for implementing dictionary search, insertion and deletion Each operation
More informationMultidimensional Indexes [14]
CMSC 661, Principles of Database Systems Multidimensional Indexes [14] Dr. Kalpakis http://www.csee.umbc.edu/~kalpakis/courses/661 Motivation Examined indexes when search keys are in 1-D space Many interesting
More informationCS256 Applied Theory of Computation
CS256 Applied Theory of Computation Parallel Computation IV John E Savage Overview PRAM Work-time framework for parallel algorithms Prefix computations Finding roots of trees in a forest Parallel merging
More informationParallel Random Access Machine (PRAM)
PRAM Algorithms Parallel Random Access Machine (PRAM) Collection of numbered processors Access shared memory Each processor could have local memory (registers) Each processor can access any shared memory
More informationPhysical Level of Databases: B+-Trees
Physical Level of Databases: B+-Trees Adnan YAZICI Computer Engineering Department METU (Fall 2005) 1 B + -Tree Index Files l Disadvantage of indexed-sequential files: performance degrades as file grows,
More informationV Advanced Data Structures
V Advanced Data Structures B-Trees Fibonacci Heaps 18 B-Trees B-trees are similar to RBTs, but they are better at minimizing disk I/O operations Many database systems use B-trees, or variants of them,
More information9/29/2016. Chapter 4 Trees. Introduction. Terminology. Terminology. Terminology. Terminology
Introduction Chapter 4 Trees for large input, even linear access time may be prohibitive we need data structures that exhibit average running times closer to O(log N) binary search tree 2 Terminology recursive
More informationTrees (Part 1, Theoretical) CSE 2320 Algorithms and Data Structures University of Texas at Arlington
Trees (Part 1, Theoretical) CSE 2320 Algorithms and Data Structures University of Texas at Arlington 1 Trees Trees are a natural data structure for representing specific data. Family trees. Organizational
More informationV Advanced Data Structures
V Advanced Data Structures B-Trees Fibonacci Heaps 18 B-Trees B-trees are similar to RBTs, but they are better at minimizing disk I/O operations Many database systems use B-trees, or variants of them,
More informationScan Primitives for GPU Computing
Scan Primitives for GPU Computing Agenda What is scan A naïve parallel scan algorithm A work-efficient parallel scan algorithm Parallel segmented scan Applications of scan Implementation on CUDA 2 Prefix
More informationFundamental Algorithms
Fundamental Algorithms Chapter 4: Parallel Algorithms The PRAM Model Michael Bader, Kaveh Rahnema Winter 2011/12 Chapter 4: Parallel Algorithms The PRAM Model, Winter 2011/12 1 Example: Parallel Searching
More informationIntroduction. for large input, even access time may be prohibitive we need data structures that exhibit times closer to O(log N) binary search tree
Chapter 4 Trees 2 Introduction for large input, even access time may be prohibitive we need data structures that exhibit running times closer to O(log N) binary search tree 3 Terminology recursive definition
More informationThe PRAM model. A. V. Gerbessiotis CIS 485/Spring 1999 Handout 2 Week 2
The PRAM model A. V. Gerbessiotis CIS 485/Spring 1999 Handout 2 Week 2 Introduction The Parallel Random Access Machine (PRAM) is one of the simplest ways to model a parallel computer. A PRAM consists of
More informationChapter 12: Indexing and Hashing. Basic Concepts
Chapter 12: Indexing and Hashing! Basic Concepts! Ordered Indices! B+-Tree Index Files! B-Tree Index Files! Static Hashing! Dynamic Hashing! Comparison of Ordered Indexing and Hashing! Index Definition
More informationCS 350 : Data Structures B-Trees
CS 350 : Data Structures B-Trees David Babcock (courtesy of James Moscola) Department of Physical Sciences York College of Pennsylvania James Moscola Introduction All of the data structures that we ve
More informationIE 495 Lecture 3. Septermber 5, 2000
IE 495 Lecture 3 Septermber 5, 2000 Reading for this lecture Primary Miller and Boxer, Chapter 1 Aho, Hopcroft, and Ullman, Chapter 1 Secondary Parberry, Chapters 3 and 4 Cosnard and Trystram, Chapter
More informationCMPS 2200 Fall 2017 B-trees Carola Wenk
CMPS 2200 Fall 2017 B-trees Carola Wenk 9/18/17 CMPS 2200 Intro. to Algorithms 1 External memory dictionary Task: Given a large amount of data that does not fit into main memory, process it into a dictionary
More informationChapter 11: Indexing and Hashing
Chapter 11: Indexing and Hashing Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 11: Indexing and Hashing Basic Concepts Ordered Indices B + -Tree Index Files B-Tree
More informationOutline. Definition. 2 Height-Balance. 3 Searches. 4 Rotations. 5 Insertion. 6 Deletions. 7 Reference. 1 Every node is either red or black.
Outline 1 Definition Computer Science 331 Red-Black rees Mike Jacobson Department of Computer Science University of Calgary Lectures #20-22 2 Height-Balance 3 Searches 4 Rotations 5 s: Main Case 6 Partial
More informationChapter 12: Indexing and Hashing
Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B+-Tree Index Files B-Tree Index Files Static Hashing Dynamic Hashing Comparison of Ordered Indexing and Hashing Index Definition in SQL
More informationModule 4: Index Structures Lecture 13: Index structure. The Lecture Contains: Index structure. Binary search tree (BST) B-tree. B+-tree.
The Lecture Contains: Index structure Binary search tree (BST) B-tree B+-tree Order file:///c /Documents%20and%20Settings/iitkrana1/My%20Documents/Google%20Talk%20Received%20Files/ist_data/lecture13/13_1.htm[6/14/2012
More informationChapter 20: Binary Trees
Chapter 20: Binary Trees 20.1 Definition and Application of Binary Trees Definition and Application of Binary Trees Binary tree: a nonlinear linked list in which each node may point to 0, 1, or two other
More informationBinary Trees
Binary Trees 4-7-2005 Opening Discussion What did we talk about last class? Do you have any code to show? Do you have any questions about the assignment? What is a Tree? You are all familiar with what
More informationCS 598: Communication Cost Analysis of Algorithms Lecture 15: Communication-optimal sorting and tree-based algorithms
CS 598: Communication Cost Analysis of Algorithms Lecture 15: Communication-optimal sorting and tree-based algorithms Edgar Solomonik University of Illinois at Urbana-Champaign October 12, 2016 Defining
More informationTrees. CSE 373 Data Structures
Trees CSE 373 Data Structures Readings Reading Chapter 7 Trees 2 Why Do We Need Trees? Lists, Stacks, and Queues are linear relationships Information often contains hierarchical relationships File directories
More informationCS350: Data Structures B-Trees
B-Trees James Moscola Department of Engineering & Computer Science York College of Pennsylvania James Moscola Introduction All of the data structures that we ve looked at thus far have been memory-based
More informationParadigms for Parallel Algorithms
S Parallel Algorithms Paradigms for Parallel Algorithms Reference : C. Xavier and S. S. Iyengar, Introduction to Parallel Algorithms Binary Tree Paradigm A binary tree with n nodes is of height log n Can
More informationCS 231 Data Structures and Algorithms Fall Recursion and Binary Trees Lecture 21 October 24, Prof. Zadia Codabux
CS 231 Data Structures and Algorithms Fall 2018 Recursion and Binary Trees Lecture 21 October 24, 2018 Prof. Zadia Codabux 1 Agenda ArrayQueue.java Recursion Binary Tree Terminologies Traversal 2 Administrative
More information4. Trees. 4.1 Preliminaries. 4.2 Binary trees. 4.3 Binary search trees. 4.4 AVL trees. 4.5 Splay trees. 4.6 B-trees. 4. Trees
4. Trees 4.1 Preliminaries 4.2 Binary trees 4.3 Binary search trees 4.4 AVL trees 4.5 Splay trees 4.6 B-trees Malek Mouhoub, CS340 Fall 2002 1 4.1 Preliminaries A Root B C D E F G Height=3 Leaves H I J
More informationThe PRAM Model. Alexandre David
The PRAM Model Alexandre David 1.2.05 1 Outline Introduction to Parallel Algorithms (Sven Skyum) PRAM model Optimality Examples 11-02-2008 Alexandre David, MVP'08 2 2 Standard RAM Model Standard Random
More informationCSE 214 Computer Science II Introduction to Tree
CSE 214 Computer Science II Introduction to Tree Fall 2017 Stony Brook University Instructor: Shebuti Rayana shebuti.rayana@stonybrook.edu http://www3.cs.stonybrook.edu/~cse214/sec02/ Tree Tree is a non-linear
More informationCSE 230 Intermediate Programming in C and C++ Binary Tree
CSE 230 Intermediate Programming in C and C++ Binary Tree Fall 2017 Stony Brook University Instructor: Shebuti Rayana shebuti.rayana@stonybrook.edu Introduction to Tree Tree is a non-linear data structure
More informationFundamental Algorithms
Fundamental Algorithms Chapter 6: Parallel Algorithms The PRAM Model Jan Křetínský Winter 2017/18 Chapter 6: Parallel Algorithms The PRAM Model, Winter 2017/18 1 Example: Parallel Sorting Definition Sorting
More information13.4 Deletion in red-black trees
Deletion in a red-black tree is similar to insertion. Apply the deletion algorithm for binary search trees. Apply node color changes and left/right rotations to fix the violations of RBT tree properties.
More informationTree traversals and binary trees
Tree traversals and binary trees Comp Sci 1575 Data Structures Valgrind Execute valgrind followed by any flags you might want, and then your typical way to launch at the command line in Linux. Assuming
More informationChapter 11: Indexing and Hashing
Chapter 11: Indexing and Hashing Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 11: Indexing and Hashing Basic Concepts Ordered Indices B + -Tree Index Files B-Tree
More informationPriority Queues. 1 Introduction. 2 Naïve Implementations. CSci 335 Software Design and Analysis III Chapter 6 Priority Queues. Prof.
Priority Queues 1 Introduction Many applications require a special type of queuing in which items are pushed onto the queue by order of arrival, but removed from the queue based on some other priority
More informationMulti-way Search Trees
Multi-way Search Trees Kuan-Yu Chen ( 陳冠宇 ) 2018/10/24 @ TR-212, NTUST Review Red-Black Trees Splay Trees Huffman Trees 2 Multi-way Search Trees. Every node in a binary search tree contains one value and
More informationUses for Trees About Trees Binary Trees. Trees. Seth Long. January 31, 2010
Uses for About Binary January 31, 2010 Uses for About Binary Uses for Uses for About Basic Idea Implementing Binary Example: Expression Binary Search Uses for Uses for About Binary Uses for Storage Binary
More informationChapter 12: Indexing and Hashing
Chapter 12: Indexing and Hashing Database System Concepts, 5th Ed. See www.db-book.com for conditions on re-use Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B + -Tree Index Files B-Tree
More informationMultiway Search Trees. Multiway-Search Trees (cont d)
Multiway Search Trees Each internal node v of a multi-way search tree T has at least two children contains d-1 items, where d is the number of children of v an item is of the form (k i,x i ) for 1 i d-1,
More information: Parallel Algorithms Exercises, Batch 1. Exercise Day, Tuesday 18.11, 10:00. Hand-in before or at Exercise Day
184.727: Parallel Algorithms Exercises, Batch 1. Exercise Day, Tuesday 18.11, 10:00. Hand-in before or at Exercise Day Jesper Larsson Träff, Francesco Versaci Parallel Computing Group TU Wien October 16,
More informationDATA STRUCTURES AND ALGORITHMS. Hierarchical data structures: AVL tree, Bayer tree, Heap
DATA STRUCTURES AND ALGORITHMS Hierarchical data structures: AVL tree, Bayer tree, Heap Summary of the previous lecture TREE is hierarchical (non linear) data structure Binary trees Definitions Full tree,
More informationCS 234. Module 8. November 15, CS 234 Module 8 ADT Priority Queue 1 / 22
CS 234 Module 8 November 15, 2018 CS 234 Module 8 ADT Priority Queue 1 / 22 ADT Priority Queue Data: (key, element pairs) where keys are orderable but not necessarily distinct, and elements are any data.
More informationCSIT5300: Advanced Database Systems
CSIT5300: Advanced Database Systems L08: B + -trees and Dynamic Hashing Dr. Kenneth LEUNG Department of Computer Science and Engineering The Hong Kong University of Science and Technology Hong Kong SAR,
More informationLecture 3: B-Trees. October Lecture 3: B-Trees
October 2017 Remarks Search trees The dynamic set operations search, minimum, maximum, successor, predecessor, insert and del can be performed efficiently (in O(log n) time) if the search tree is balanced.
More information18.3 Deleting a key from a B-tree
18.3 Deleting a key from a B-tree B-TREE-DELETE deletes the key from the subtree rooted at We design it to guarantee that whenever it calls itself recursively on a node, the number of keys in is at least
More information8. Binary Search Tree
8 Binary Search Tree Searching Basic Search Sequential Search : Unordered Lists Binary Search : Ordered Lists Tree Search Binary Search Tree Balanced Search Trees (Skipped) Sequential Search int Seq-Search
More informationCSL 730: Parallel Programming
CSL 73: Parallel Programming General Algorithmic Techniques Balance binary tree Partitioning Divid and conquer Fractional cascading Recursive doubling Symmetry breaking Pipelining 2 PARALLEL ALGORITHM
More informationCSL 730: Parallel Programming. Algorithms
CSL 73: Parallel Programming Algorithms First 1 problem Input: n-bit vector Output: minimum index of a 1-bit First 1 problem Input: n-bit vector Output: minimum index of a 1-bit Algorithm: Divide into
More informationWe assume uniform hashing (UH):
We assume uniform hashing (UH): the probe sequence of each key is equally likely to be any of the! permutations of 0,1,, 1 UH generalizes the notion of SUH that produces not just a single number, but a
More informationTransform & Conquer. Presorting
Transform & Conquer Definition Transform & Conquer is a general algorithm design technique which works in two stages. STAGE : (Transformation stage): The problem s instance is modified, more amenable to
More informationTREES. Trees - Introduction
TREES Chapter 6 Trees - Introduction All previous data organizations we've studied are linear each element can have only one predecessor and successor Accessing all elements in a linear sequence is O(n)
More informationTrees. Tree Structure Binary Tree Tree Traversals
Trees Tree Structure Binary Tree Tree Traversals The Tree Structure Consists of nodes and edges that organize data in a hierarchical fashion. nodes store the data elements. edges connect the nodes. The
More informationTrees. Q: Why study trees? A: Many advance ADTs are implemented using tree-based data structures.
Trees Q: Why study trees? : Many advance DTs are implemented using tree-based data structures. Recursive Definition of (Rooted) Tree: Let T be a set with n 0 elements. (i) If n = 0, T is an empty tree,
More informationDDS Dynamic Search Trees
DDS Dynamic Search Trees 1 Data structures l A data structure models some abstract object. It implements a number of operations on this object, which usually can be classified into l creation and deletion
More informationParallel Random-Access Machines
Parallel Random-Access Machines Marc Moreno Maza University of Western Ontario, London, Ontario (Canada) CS3101 (Moreno Maza) Parallel Random-Access Machines CS3101 1 / 69 Plan 1 The PRAM Model 2 Performance
More informationAlgorithms. Deleting from Red-Black Trees B-Trees
Algorithms Deleting from Red-Black Trees B-Trees Recall the rules for BST deletion 1. If vertex to be deleted is a leaf, just delete it. 2. If vertex to be deleted has just one child, replace it with that
More informationAn AVL tree with N nodes is an excellent data. The Big-Oh analysis shows that most operations finish within O(log N) time
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 finish within O(log N) time The theoretical conclusion
More informationTrees, Part 1: Unbalanced Trees
Trees, Part 1: Unbalanced Trees The first part of this chapter takes a look at trees in general and unbalanced binary trees. The second part looks at various schemes to balance trees and/or make them more
More informationBinary Search Trees. Contents. Steven J. Zeil. July 11, Definition: Binary Search Trees The Binary Search Tree ADT...
Steven J. Zeil July 11, 2013 Contents 1 Definition: Binary Search Trees 2 1.1 The Binary Search Tree ADT.................................................... 3 2 Implementing Binary Search Trees 7 2.1 Searching
More informationRecall: Properties of B-Trees
CSE 326 Lecture 10: B-Trees and Heaps It s lunch time what s cookin? B-Trees Insert/Delete Examples and Run Time Analysis Summary of Search Trees Introduction to Heaps and Priority Queues Covered in Chapters
More informationBalanced Search Trees. CS 3110 Fall 2010
Balanced Search Trees CS 3110 Fall 2010 Some Search Structures Sorted Arrays Advantages Search in O(log n) time (binary search) Disadvantages Need to know size in advance Insertion, deletion O(n) need
More informationChapter 12: Indexing and Hashing (Cnt(
Chapter 12: Indexing and Hashing (Cnt( Cnt.) Basic Concepts Ordered Indices B+-Tree Index Files B-Tree Index Files Static Hashing Dynamic Hashing Comparison of Ordered Indexing and Hashing Index Definition
More informationChapter 10: Trees. A tree is a connected simple undirected graph with no simple circuits.
Chapter 10: Trees A tree is a connected simple undirected graph with no simple circuits. Properties: o There is a unique simple path between any 2 of its vertices. o No loops. o No multiple edges. Example
More information2-3 and Trees. COL 106 Shweta Agrawal, Amit Kumar, Dr. Ilyas Cicekli
2-3 and 2-3-4 Trees COL 106 Shweta Agrawal, Amit Kumar, Dr. Ilyas Cicekli Multi-Way Trees A binary search tree: One value in each node At most 2 children An M-way search tree: Between 1 to (M-1) values
More information1. (a) O(log n) algorithm for finding the logical AND of n bits with n processors
1. (a) O(log n) algorithm for finding the logical AND of n bits with n processors on an EREW PRAM: See solution for the next problem. Omit the step where each processor sequentially computes the AND of
More informationMarch 20/2003 Jayakanth Srinivasan,
Definition : A simple graph G = (V, E) consists of V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements of V called edges. Definition : In a multigraph G = (V, E) two or
More informationIntro to DB CHAPTER 12 INDEXING & HASHING
Intro to DB CHAPTER 12 INDEXING & HASHING Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B+-Tree Index Files B-Tree Index Files Static Hashing Dynamic Hashing Comparison of Ordered Indexing
More informationChapter 4: Trees. 4.2 For node B :
Chapter : Trees. (a) A. (b) G, H, I, L, M, and K.. For node B : (a) A. (b) D and E. (c) C. (d). (e).... There are N nodes. Each node has two pointers, so there are N pointers. Each node but the root has
More informationINDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator EXAMINATION ( End Semester ) SEMESTER ( Autumn ) Roll Number Section Name Subject Number C S 6 0 0 2 6 Subject Name Parallel
More informationCSE 5095 Topics in Big Data Analytics Spring 2014; Homework 1 Solutions
CSE 5095 Topics in Big Data Analytics Spring 2014; Homework 1 Solutions Note: Solutions to problems 4, 5, and 6 are due to Marius Nicolae. 1. Consider the following algorithm: for i := 1 to α n log e n
More informationTree: non-recursive definition. Trees, Binary Search Trees, and Heaps. Tree: recursive definition. Tree: example.
Trees, Binary Search Trees, and Heaps CS 5301 Fall 2013 Jill Seaman Tree: non-recursive definition Tree: set of nodes and directed edges - root: one node is distinguished as the root - Every node (except
More informationTrees. Eric McCreath
Trees Eric McCreath 2 Overview In this lecture we will explore: general trees, binary trees, binary search trees, and AVL and B-Trees. 3 Trees Trees are recursive data structures. They are useful for:
More informationBinary Trees and Huffman Encoding Binary Search Trees
Binary Trees and Huffman Encoding Binary Search Trees Computer Science E-22 Harvard Extension School David G. Sullivan, Ph.D. Motivation: Maintaining a Sorted Collection of Data A data dictionary is a
More informationThe divide-and-conquer paradigm involves three steps at each level of the recursion: Divide the problem into a number of subproblems.
2.3 Designing algorithms There are many ways to design algorithms. Insertion sort uses an incremental approach: having sorted the subarray A[1 j - 1], we insert the single element A[j] into its proper
More informationHypercubes. (Chapter Nine)
Hypercubes (Chapter Nine) Mesh Shortcomings: Due to its simplicity and regular structure, the mesh is attractive, both theoretically and practically. A problem with the mesh is that movement of data is
More information9/24/ Hash functions
11.3 Hash functions A good hash function satis es (approximately) the assumption of SUH: each key is equally likely to hash to any of the slots, independently of the other keys We typically have no way
More informationMulti-Way Search Tree
Multi-Way Search Tree A multi-way search tree is an ordered tree such that Each internal node has at least two and at most d children and stores d -1 data items (k i, D i ) Rule: Number of children = 1
More informationCSE Introduction to Parallel Processing. Chapter 5. PRAM and Basic Algorithms
Dr Izadi CSE-40533 Introduction to Parallel Processing Chapter 5 PRAM and Basic Algorithms Define PRAM and its various submodels Show PRAM to be a natural extension of the sequential computer (RAM) Develop
More informationCSE 100 Advanced Data Structures
CSE 100 Advanced Data Structures Overview of course requirements Outline of CSE 100 topics Review of trees Helpful hints for team programming Information about computer accounts Page 1 of 25 CSE 100 web
More informationBinary Search Trees Treesort
Treesort CS 311 Data Structures and Algorithms Lecture Slides Friday, November 13, 2009 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks CHAPPELLG@member.ams.org 2005 2009
More informationComplexity and Advanced Algorithms Monsoon Parallel Algorithms Lecture 2
Complexity and Advanced Algorithms Monsoon 2011 Parallel Algorithms Lecture 2 Trivia ISRO has a new supercomputer rated at 220 Tflops Can be extended to Pflops. Consumes only 150 KW of power. LINPACK is
More informationMultiway searching. In the worst case of searching a complete binary search tree, we can make log(n) page faults Everyone knows what a page fault is?
Multiway searching What do we do if the volume of data to be searched is too large to fit into main memory Search tree is stored on disk pages, and the pages required as comparisons proceed may not be
More informationCS24 Week 8 Lecture 1
CS24 Week 8 Lecture 1 Kyle Dewey Overview Tree terminology Tree traversals Implementation (if time) Terminology Node The most basic component of a tree - the squares Edge The connections between nodes
More informationTHE B+ TREE INDEX. CS 564- Spring ACKs: Jignesh Patel, AnHai Doan
THE B+ TREE INDEX CS 564- Spring 2018 ACKs: Jignesh Patel, AnHai Doan WHAT IS THIS LECTURE ABOUT? The B+ tree index Basics Search/Insertion/Deletion Design & Cost 2 INDEX RECAP We have the following query:
More informationCMPS 2200 Fall 2017 Red-black trees Carola Wenk
CMPS 2200 Fall 2017 Red-black trees Carola Wenk Slides courtesy of Charles Leiserson with changes by Carola Wenk 9/13/17 CMPS 2200 Intro. to Algorithms 1 Dynamic Set A dynamic set, or dictionary, is a
More informationBinary Trees, Binary Search Trees
Binary Trees, Binary Search Trees Trees Linear access time of linked lists is prohibitive Does there exist any simple data structure for which the running time of most operations (search, insert, delete)
More informationModule 4: Dictionaries and Balanced Search Trees
Module 4: Dictionaries and Balanced Search Trees CS 24 - Data Structures and Data Management Jason Hinek and Arne Storjohann Based on lecture notes by R. Dorrigiv and D. Roche David R. Cheriton School
More informationDatabase System Concepts, 6 th Ed. Silberschatz, Korth and Sudarshan See for conditions on re-use
Chapter 11: Indexing and Hashing Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B + -Tree Index Files Static
More information