The Quadtree and Related Hierarchical Data Structures

Total Page:16

File Type:pdf, Size:1020Kb

The Quadtree and Related Hierarchical Data Structures The Quadtree and Related Hierarchical Data Structures HANAN SAMET Computer Sdence Department, University of Maryland, College Park, Maryland 20742 A tutorial survey is presented of the quadtree and related hierarchical data structures. They are based on the principle of recursive decomposition. The emphasis is on the representation of data used in applications in image processing, computer graphics, geographic information systems, and robotics. There is a greater emphasis on region data (i.e., two-dimensional shapes) and to a lesser extent on point, curvilinear, and three­ dimensional data. A number of operations in which such data structures find use are examined in greater detail. Categories and Subject Descriptors: E.1 [Data]: Data Structures-trees; H.3.2 [Information Storage and Retrieval]: Information Storage-file organization; 1.2.1 [Artificial Intelligence]: Applications and Expert Systems-cartography; 1.2.10 [Artificial Intelligence): Vision and Scene Understanding-representations, data structures, and transforms; 1.3.3 [Computer Graphics]: Picture/Image Generation­ display algorithms; viewing algorithms; 1.3.5 [Computer Graphics]: Computational Geometry and Object Modeling-curve, surface, solid, and object representations; geometric algorithms, languages, and systems; l.4.2 [Image Processing]: Compression (Coding)-approximate methods; exact coding; 1.4. 7 [Image Processing]: Feature Measurement-moments; projections; size and shape; J.6 [Computer-Aided Engineering]: Computer-Aided Design (CAD) General Terms: Algorithms Additional Key Words and Phrases: Geographic information systems, hierarchical data structures, image databases, multiattribute data, multidimensional data structures, octrees, pattern recognition, point data, quadtrees, robotics INTRODUCTION structures used in different domains are related to each other and to quadtrees. This Hierarchical data structures are becoming presentation concentrates on these differ­ increasingly important representation tech­ ent representations and illustrates how a niques in the domains of computer graph­ number of basic operations that use them ics, image processing, computational geom­ are performed. etry, geographic information systems, and Hierarchical data structures are useful robotics. They are based on the principle of because of their ability to focus on the recursive decomposition (similar to divide interesting subsets of the data. This focus­ and conquer methods [Aho et al. 1974]). ing results in an efficient representation One such data structure is the quadtree. As and improved execution times and is thus we shall see, the term quadtree has taken particularly useful for performing set op­ on a generic meaning. In this survey it is erations. Many of the operations that we our goal to show how a number of data describe can often be performed equally as Permission to copy without fee all or part of this material is granted provided that the copies are not made or distributed for direct commercial advantage, the ACM copyright notice and the title of the publication and its date appear, and notice is given that copying is by permission of the Association for Computing Machinery. To copy otherwise, or to republish, requires a fee and/or specific permission. © 1984 ACM 0360-0300/84/0600-0187 $00.75 Computing Surveys, Vol.16, No. 2, June 1984 188 • Hanan Samet CONTENTS of no interest, and we wish to spend a minimal amount of effort searching such regions. Yet, traditional region representa­ tions such as the boundary code [Freeman INTRODUCTION 1974] are very local in application, making 1. OVERVIEW OF QUADTREES it difficult to avoid examining a corn-grow­ 2. REGION DATA ing area that meets the desired elevation 2.1 Neighbor-Finding Techniques 2.2 Alternative Ways to Represent Quadtrees criterion. In contrast, hierarchical methods 2.3 Conversion such as the region quadtree are more global 2.4 Set Operations in nature and enable the elimination of 2.5 Transformations larger areas from consideration. Another 2.6 Areas and Moments query might be to determine whether two 2. 7 Connected Component Labeling 2.8 Perimeter roads intersect within a given area. We 2.9 Component Counting could check them point by point, but a more 2.10 Space Requirements efficient method of analysis would be to 2.11 Skeletons and Medial Axis Transforms represent them by a hierarchical sequence 2.12 Pyramids 2.13 Quadtree Approximation Methods of enclosing rectangles and to discover 2.14 Volume Data whether in fact the rectangles do overlap. 3. POINT DATA If they do not, then the search is termi­ 3.1 Point Quadtrees and k-d Trees nated, but if an intersection is possible, 3.2 Region-Based Qualities 3.3 Comparison of Point Quadtrees then more work may have to be done, de­ and Region-Based Quadtrees pending on which method of representation 3.4 CIF Quadtrees is used. A similar query can be constructed 3.5 Bucket Methods for point data-for example, to determine 4. CURVILINEAR DATA all cities within 50 miles of St. Louis that 4.1 Strip Trees 4.2 Methods Based on a Regular Decomposition have a population in excess of 20,000 peo­ 4.3 Comparison ple. Again, we could check each city indi­ 5. CONCLUSIONS vidually, but using a representation that ACKNOWLEDGMENTS decomposes the United States into square REFERENCES areas having sides of length 100 miles would mean that at most four squares need to be examined. Thus California and its adjacent states can be safely ignored. Finally, sup­ efficiently, or more so, with other data pose that we wish to integrate our queries structures. However, hierarchical data over a database containing many different structures are attractive because of their types of data (e.g., points, lines, and areas). conceptual clarity and ease of implemen­ A typical query might be, "Find all cities tation. with a population in excess of 5000 people As an example of the type of problems to in wheat-growing regions within 20 miles which the techniques described in this sur­ of the Mississippi River." In the remainder vey are applicable, consider a cartographic of this survey we shall present a number of database consisting of a number of maps different ways of representing data so that and some typical queries. The database such queries and other operations can be contains a contour map, say at 50-foot ele­ efficiently processed. vation intervals, and a land use map clas­ The coverage and scope of the survey are sifying areas according to crop growth. Our focused on region data, and are concerned wish is to determine all regions between to a lesser extent witli point, curvilinear, 400- and 600-foot elevation levels where and three-dimensional data. Owing to space wheat is grown. This will require an inter­ limitations, algorithms are presented only section operation on the two maps. Such in a descriptive manner. Whenever possi­ an analysis could be rather costly, depend­ ble, however, we have tried to motivate ing on the way the data are represented. critical steps by a liberal use of examples. For example, areas where corn is grown are The concept of a pyramid is discussed only Computing Surveys, Vol. 16, No. 2, June 1984 The Quadtree and Related Hierarchical Data Structures • 189 briefly, and the reader is referred to the position process is applied) may be fixed collection of papers edited by Rosenfeld beforehand, or it may be governed by prop­ [1983] for a more comprehensive exposi­ erties of the input data. tion. Similarly, we discuss image compres­ Our first example of quadtree represen­ sion and coding only in the context of hi­ tation of data is concerned with the repre­ erarchical data structures. Results from sentation of region data. The most studied computational geometry, although related quadtree approach to region representa­ to many of the topics covered in this survey, tion, termed a region quadtree, is based on are only discussed briefly in the context of the successive subdivision of the image ar­ representations for curvilinear data. For ray into four equal-sized quadrants. If the more details on early results involving some array does not consist entirely of l's or of these and related topics, the interested entirely ofO's (i.e., the region does not cover reader may consult the surveys by Bent­ the entire array), it is then subdivided into ley and Friedman [1979], Edelsbrunner quadrants, subquadrants, etc. until blocks [1984), Nagy and Wagle [1979], Requicha are obtained (possibly single pixels) that [1980), Srihari [1981], Samet and Rosen­ consist entirely of l's or entirely of O's; that feld [1980], and Toussaint [1980]. Over­ is, each block is entirely contained in the mars (1983] has produced a particularly region or entirely disjoint from it. Thus the good treatment of point data. A broader region quadtree can be characterized as a view of the literature can be found in re­ variable resolution data structure. For ex­ lated bibliographies, for example, Edels­ ample, consider the region shown in Figure brunner and van Leeuwen [1983] and Ro­ la, which is represented by the 23 by 23 senfeld [1984]. Nevertheless, given the binary array in Figure lb. Observe that the broad and rapidly expanding nature of the l's correspond to picture elements (termed field, we are bound to have omitted signif­ pixe/,s) that are in the region and the O's icant concepts and references. In addition correspond to picture elements that are we at times devote a disproportionate outside the region. The resulting blocks for amount of attention to some concepts at the array of Figure lb are shown in Figure the expense of others. This is principally le. This process is represented by a tree of for expository purposes as we feel that it is degree 4 (i.e., each nonleaf node has four better to understand some structures well sons). The root node corresponds to the rather than to give the reader a quick run­ entire array.
Recommended publications
  • Traits: Experience with a Language Feature
    7UDLWV([SHULHQFHZLWKD/DQJXDJH)HDWXUH (PHUVRQ50XUSK\+LOO $QGUHZ3%ODFN 7KH(YHUJUHHQ6WDWH&ROOHJH 2*,6FKRRORI6FLHQFH1(QJLQHHULQJ$ (YHUJUHHQ3DUNZD\1: 2UHJRQ+HDOWKDQG6FLHQFH8QLYHUVLW\ 2O\PSLD$:$ 1::DONHU5G PXUHPH#HYHUJUHHQHGX %HDYHUWRQ$25 EODFN#FVHRJLHGX ABSTRACT the desired semantics of that method changes, or if a bug is This paper reports our experiences using traits, collections of found, the programmer must track down and fix every copy. By pure methods designed to promote reuse and understandability reusing a method, behavior can be defined and maintained in in object-oriented programs. Traits had previously been used to one place. refactor the Smalltalk collection hierarchy, but only by the crea- tors of traits themselves. This experience report represents the In object-oriented programming, inheritance is the normal way first independent test of these language features. Murphy-Hill of reusing methods—classes inherit methods from other classes. implemented a substantial multi-class data structure called ropes Single inheritance is the most basic and most widespread type of that makes significant use of traits. We found that traits im- inheritance. It allows methods to be shared among classes in an proved understandability and reduced the number of methods elegant and efficient way, but does not always allow for maxi- that needed to be written by 46%. mum reuse. Consider a small example. In Squeak [7], a dialect of Smalltalk, Categories and Subject Descriptors the class &ROOHFWLRQ is the superclass of all the classes that $UUD\ +HDS D.2.3 [Programming Languages]: Coding Tools and Tech- implement collection data structures, including , , 6HW niques - object-oriented programming and . The property of being empty is common to many ob- jects—it simply requires that the object have a size method, and D.3.3 [Programming Languages]: Language Constructs and that the method returns zero.
    [Show full text]
  • L11: Quadtrees CSE373, Winter 2020
    L11: Quadtrees CSE373, Winter 2020 Quadtrees CSE 373 Winter 2020 Instructor: Hannah C. Tang Teaching Assistants: Aaron Johnston Ethan Knutson Nathan Lipiarski Amanda Park Farrell Fileas Sam Long Anish Velagapudi Howard Xiao Yifan Bai Brian Chan Jade Watkins Yuma Tou Elena Spasova Lea Quan L11: Quadtrees CSE373, Winter 2020 Announcements ❖ Homework 4: Heap is released and due Wednesday ▪ Hint: you will need an additional data structure to improve the runtime for changePriority(). It does not affect the correctness of your PQ at all. Please use a built-in Java collection instead of implementing your own. ▪ Hint: If you implemented a unittest that tested the exact thing the autograder described, you could run the autograder’s test in the debugger (and also not have to use your tokens). ❖ Please look at posted QuickCheck; we had a few corrections! 2 L11: Quadtrees CSE373, Winter 2020 Lecture Outline ❖ Heaps, cont.: Floyd’s buildHeap ❖ Review: Set/Map data structures and logarithmic runtimes ❖ Multi-dimensional Data ❖ Uniform and Recursive Partitioning ❖ Quadtrees 3 L11: Quadtrees CSE373, Winter 2020 Other Priority Queue Operations ❖ The two “primary” PQ operations are: ▪ removeMax() ▪ add() ❖ However, because PQs are used in so many algorithms there are three common-but-nonstandard operations: ▪ merge(): merge two PQs into a single PQ ▪ buildHeap(): reorder the elements of an array so that its contents can be interpreted as a valid binary heap ▪ changePriority(): change the priority of an item already in the heap 4 L11: Quadtrees CSE373,
    [Show full text]
  • Search Trees
    Lecture III Page 1 “Trees are the earth’s endless effort to speak to the listening heaven.” – Rabindranath Tagore, Fireflies, 1928 Alice was walking beside the White Knight in Looking Glass Land. ”You are sad.” the Knight said in an anxious tone: ”let me sing you a song to comfort you.” ”Is it very long?” Alice asked, for she had heard a good deal of poetry that day. ”It’s long.” said the Knight, ”but it’s very, very beautiful. Everybody that hears me sing it - either it brings tears to their eyes, or else -” ”Or else what?” said Alice, for the Knight had made a sudden pause. ”Or else it doesn’t, you know. The name of the song is called ’Haddocks’ Eyes.’” ”Oh, that’s the name of the song, is it?” Alice said, trying to feel interested. ”No, you don’t understand,” the Knight said, looking a little vexed. ”That’s what the name is called. The name really is ’The Aged, Aged Man.’” ”Then I ought to have said ’That’s what the song is called’?” Alice corrected herself. ”No you oughtn’t: that’s another thing. The song is called ’Ways and Means’ but that’s only what it’s called, you know!” ”Well, what is the song then?” said Alice, who was by this time completely bewildered. ”I was coming to that,” the Knight said. ”The song really is ’A-sitting On a Gate’: and the tune’s my own invention.” So saying, he stopped his horse and let the reins fall on its neck: then slowly beating time with one hand, and with a faint smile lighting up his gentle, foolish face, he began..
    [Show full text]
  • The Cedar Programming Environment: a Midterm Report and Examination
    The Cedar Programming Environment: A Midterm Report and Examination Warren Teitelman The Cedar Programming Environment: A Midterm Report and Examination Warren Teitelman t CSL-83-11 June 1984 [P83-00012] © Copyright 1984 Xerox Corporation. All rights reserved. CR Categories and Subject Descriptors: D.2_6 [Software Engineering]: Programming environments. Additional Keywords and Phrases: integrated programming environment, experimental programming, display oriented user interface, strongly typed programming language environment, personal computing. t The author's present address is: Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, Ca. 94043. The work described here was performed while employed by Xerox Corporation. XEROX Xerox Corporation Palo Alto Research Center 3333 Coyote Hill Road Palo Alto, California 94304 1 Abstract: This collection of papers comprises a report on Cedar, a state-of-the-art programming system. Cedar combines in a single integrated environment: high-quality graphics, a sophisticated editor and document preparation facility, and a variety of tools for the programmer to use in the construction and debugging of his programs. The Cedar Programming Language is a strongly-typed, compiler-oriented language of the Pascal family. What is especially interesting about the Ce~ar project is that it is one of the few examples where an interactive, experimental programming environment has been built for this kind of language. In the past, such environments have been confined to dynamically typed languages like Lisp and Smalltalk. The first paper, "The Roots of Cedar," describes the conditions in 1978 in the Xerox Palo Alto Research Center's Computer Science Laboratory that led us to embark on the Cedar project and helped to define its objectives and goals.
    [Show full text]
  • Smalltalk Idioms
    Smalltalk Idioms Farewell and a wood pile Kent Beck IT’S THE OBJECTS, STUPID If we parsed the string “@years”, the resulting picture S me awhile to see the obvious. Some- would look like Figure 6. When the BinaryFunction un- times even longer than that. Three or four times in the wraps its children, the right function will be in place. last month I’ve been confronted by problems I had a As I said, several times in the last month I’ve faced hard time solving. In each case, the answer became clear baffling problems that became easy when I asked myself when I asked myself the simple question, “How can I the question, “How could I make an object to solve this make an object to solve this problem for me?” You think problem for me?” Sometimes it was a method that just I’d have figured it out by now: got a problem? make an didn’t want to be simplified, so I created an object just for object for it. that method. Sometimes it was a question of adding Here’s an example: I had to write an editor for a tree features to an object for a particular purpose without clut- structure. There were several ways of viewing and editing tering the object (as in the editing example). I recommend the tree. On the left was a hierarchical list. On the top right that the next time you run into a problem that just doesn’t was a text editor on the currently selected node of the tree.
    [Show full text]
  • The Skip Quadtree: a Simple Dynamic Data Structure for Multidimensional Data
    The Skip Quadtree: A Simple Dynamic Data Structure for Multidimensional Data David Eppstein† Michael T. Goodrich† Jonathan Z. Sun† Abstract We present a new multi-dimensional data structure, which we call the skip quadtree (for point data in R2) or the skip octree (for point data in Rd , with constant d > 2). Our data structure combines the best features of two well-known data structures, in that it has the well-defined “box”-shaped regions of region quadtrees and the logarithmic-height search and update hierarchical structure of skip lists. Indeed, the bottom level of our structure is exactly a region quadtree (or octree for higher dimensional data). We describe efficient algorithms for inserting and deleting points in a skip quadtree, as well as fast methods for performing point location and approximate range queries. 1 Introduction Data structures for multidimensional point data are of significant interest in the computational geometry, computer graphics, and scientific data visualization literatures. They allow point data to be stored and searched efficiently, for example to perform range queries to report (possibly approximately) the points that are contained in a given query region. We are interested in this paper in data structures for multidimensional point sets that are dynamic, in that they allow for fast point insertion and deletion, as well as efficient, in that they use linear space and allow for fast query times. Related Previous Work. Linear-space multidimensional data structures typically are defined by hierar- chical subdivisions of space, which give rise to tree-based search structures. That is, a hierarchy is defined by associating with each node v in a tree T a region R(v) in Rd such that the children of v are associated with subregions of R(v) defined by some kind of “cutting” action on R(v).
    [Show full text]
  • Effective STL
    Effective STL Author: Scott Meyers E-version is made by: Strangecat@epubcn Thanks is given to j1foo@epubcn, who has helped to revise this e-book. Content Containers........................................................................................1 Item 1. Choose your containers with care........................................................... 1 Item 2. Beware the illusion of container-independent code................................ 4 Item 3. Make copying cheap and correct for objects in containers..................... 9 Item 4. Call empty instead of checking size() against zero. ............................. 11 Item 5. Prefer range member functions to their single-element counterparts... 12 Item 6. Be alert for C++'s most vexing parse................................................... 20 Item 7. When using containers of newed pointers, remember to delete the pointers before the container is destroyed. ........................................................... 22 Item 8. Never create containers of auto_ptrs. ................................................... 27 Item 9. Choose carefully among erasing options.............................................. 29 Item 10. Be aware of allocator conventions and restrictions. ......................... 34 Item 11. Understand the legitimate uses of custom allocators........................ 40 Item 12. Have realistic expectations about the thread safety of STL containers. 43 vector and string............................................................................48 Item 13. Prefer vector
    [Show full text]
  • CS 240 – Data Structures and Data Management Module 8
    CS 240 – Data Structures and Data Management Module 8: Range-Searching in Dictionaries for Points Mark Petrick Based on lecture notes by many previous cs240 instructors David R. Cheriton School of Computer Science, University of Waterloo Fall 2020 References: Goodrich & Tamassia 21.1, 21.3 version 2020-10-27 11:48 Petrick (SCS, UW) CS240 – Module 8 Fall 2020 1 / 38 Outline 1 Range-Searching in Dictionaries for Points Range Searches Multi-Dimensional Data Quadtrees kd-Trees Range Trees Conclusion Petrick (SCS, UW) CS240 – Module 8 Fall 2020 Outline 1 Range-Searching in Dictionaries for Points Range Searches Multi-Dimensional Data Quadtrees kd-Trees Range Trees Conclusion Petrick (SCS, UW) CS240 – Module 8 Fall 2020 Range searches So far: search(k) looks for one specific item. New operation RangeSearch: look for all items that fall within a given range. 0 I Input: A range, i.e., an interval I = (x, x ) It may be open or closed at the ends. I Want: Report all KVPs in the dictionary whose key k satisfies k ∈ I Example: 5 10 11 17 19 33 45 51 55 59 RangeSerach( (18,45] ) should return {19, 33, 45} Let s be the output-size, i.e., the number of items in the range. We need Ω(s) time simply to report the items. Note that sometimes s = 0 and sometimes s = n; we therefore keep it as a separate parameter when analyzing the run-time. Petrick (SCS, UW) CS240 – Module 8 Fall 2020 2 / 38 Range searches in existing dictionary realizations Unsorted list/array/hash table: Range search requires Ω(n) time: We have to check for each item explicitly whether it is in the range.
    [Show full text]
  • The Ocaml System Release 4.02
    The OCaml system release 4.02 Documentation and user's manual Xavier Leroy, Damien Doligez, Alain Frisch, Jacques Garrigue, Didier R´emy and J´er^omeVouillon August 29, 2014 Copyright © 2014 Institut National de Recherche en Informatique et en Automatique 2 Contents I An introduction to OCaml 11 1 The core language 13 1.1 Basics . 13 1.2 Data types . 14 1.3 Functions as values . 15 1.4 Records and variants . 16 1.5 Imperative features . 18 1.6 Exceptions . 20 1.7 Symbolic processing of expressions . 21 1.8 Pretty-printing and parsing . 22 1.9 Standalone OCaml programs . 23 2 The module system 25 2.1 Structures . 25 2.2 Signatures . 26 2.3 Functors . 27 2.4 Functors and type abstraction . 29 2.5 Modules and separate compilation . 31 3 Objects in OCaml 33 3.1 Classes and objects . 33 3.2 Immediate objects . 36 3.3 Reference to self . 37 3.4 Initializers . 38 3.5 Virtual methods . 38 3.6 Private methods . 40 3.7 Class interfaces . 42 3.8 Inheritance . 43 3.9 Multiple inheritance . 44 3.10 Parameterized classes . 44 3.11 Polymorphic methods . 47 3.12 Using coercions . 50 3.13 Functional objects . 54 3.14 Cloning objects . 55 3.15 Recursive classes . 58 1 2 3.16 Binary methods . 58 3.17 Friends . 60 4 Labels and variants 63 4.1 Labels . 63 4.2 Polymorphic variants . 69 5 Advanced examples with classes and modules 73 5.1 Extended example: bank accounts . 73 5.2 Simple modules as classes .
    [Show full text]
  • Thinking in C++ 2Nd Edition Volume 2
    Thinking in C++ 2nd edition Volume 2: Standard Libraries & Advanced Topics To be informed of future releases of this document and other information about object- oriented books, documents, seminars and CDs, subscribe to my free newsletter. Just send any email to: [email protected] ________________________________________________________________________ “This book is a tremendous achievement. You owe it to yourself to have a copy on your shelf. The chapter on iostreams is the most comprehensive and understandable treatment of that subject I’ve seen to date.” Al Stevens Contributing Editor, Doctor Dobbs Journal “Eckel’s book is the only one to so clearly explain how to rethink program construction for object orientation. That the book is also an excellent tutorial on the ins and outs of C++ is an added bonus.” Andrew Binstock Editor, Unix Review “Bruce continues to amaze me with his insight into C++, and Thinking in C++ is his best collection of ideas yet. If you want clear answers to difficult questions about C++, buy this outstanding book.” Gary Entsminger Author, The Tao of Objects “Thinking in C++ patiently and methodically explores the issues of when and how to use inlines, references, operator overloading, inheritance and dynamic objects, as well as advanced topics such as the proper use of templates, exceptions and multiple inheritance. The entire effort is woven in a fabric that includes Eckel’s own philosophy of object and program design. A must for every C++ developer’s bookshelf, Thinking in C++ is the one C++ book you must have if you’re doing serious development with C++.” Richard Hale Shaw Contributing Editor, PC Magazine Thinking In C++ 2nd Edition, Volume 2 Bruce Eckel President, MindView Inc.
    [Show full text]
  • CS106X Handout
    CS106X Autumn 2015 Cynthia Lee Section 6 (Week 7) Handout Problem and solution authors include Jerry Cain and Cynthia Lee. Problem 1: Tree Rotations Recall in class we saw the video of the insertions to a red-black tree, which first followed the usual insert algorithm (go left if key being inserted is less than current, go right if greater than current), and then did additional “rotations” that rebalanced the tree. Now is your chance to explore the code that makes the rebalancing happen. Rotations have other uses; for example, in Splay trees, they can be used to migrate more commonly-used elements towards the root. Suppose that a binary search tree has grown to store the first seven integers, as has the tree drawn to the right. Suppose that a program then searches for the 5. Clearly the search would succeed, but the standard implementation would leave the node in the same position, and later searches for the same element would take the same amount of time. A cleverer implementation would anticipate another search for 5 is likely, and would change the pointer structure in the vicinity of the 5 by performing what is called a left-rotation. A left rotation pivots around the link between a node and its parent, so that the child of the link rotates counterclockwise to become the parent of its parent. In our example above, a left- rotation would change the structure according to the figure on the right. Note that the restructuring is a local operation, in that only a constant number of pointers need to be updated.
    [Show full text]
  • Geometric Search
    Geometric Search range search quad- and kD-trees • range search • quad and kd trees intersection search • intersection search VLSI rules checking • VLSI rules check References: Algorithms 2nd edition, Chapter 26-27 Intro to Algs and Data Structs, Section Copyright © 2007 by Robert Sedgewick and Kevin Wayne. 3 Overview 1D Range Search Types of data. Points, lines, planes, polygons, circles, ... Extension to symbol-table ADT with comparable keys. This lecture. Sets of N objects. ! Insert key-value pair. ! Search for key k. ! Geometric problems extend to higher dimensions. How many records have keys between k1 and k2? ! ! Good algorithms also extend to higher dimensions. Iterate over all records with keys between k1 and k2. ! Curse of dimensionality. Application: database queries. Basic problems. ! Range searching. insert B B ! Nearest neighbor. insert D B D insert A A B D ! Finding intersections of geometric objects. Geometric intuition. insert I A B D I ! Keys are point on a line. insert H A B D H I ! How many points in a given interval? insert F A B D F H I insert P A B D F H I P count G to K 2 search G to K H I 2 4 1D Range search: implementations 2D Orthogonal range Ssearch: Grid implementation Range search. How many records have keys between k1 and k2? Grid implementation. [Sedgewick 3.18] ! Divide space into M-by-M grid of squares. ! Ordered array. Slow insert, binary search for k1 and k2 to find range. Create linked list for each square. Hash table. No reasonable algorithm (key order lost in hash).
    [Show full text]