Data Structures and Algorithms

Similar documents
Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

Spatial Data Structures

Announcements. Written Assignment2 is out, due March 8 Graded Programming Assignment2 next Tuesday

Spatial Data Structures

Spatial Data Structures

Spatial Data Structures

Spatial Data Structures

Algorithms for GIS:! Quadtrees

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Lecture 25 of 41. Spatial Sorting: Binary Space Partitioning Quadtrees & Octrees

Computer Graphics. Bing-Yu Chen National Taiwan University

Spatial Data Structures and Acceleration Algorithms

Organizing Spatial Data

Module 4: Index Structures Lecture 13: Index structure. The Lecture Contains: Index structure. Binary search tree (BST) B-tree. B+-tree.

Ray Tracing: Intersection

CPSC / Sonny Chan - University of Calgary. Collision Detection II

Trees. Eric McCreath

Self-Balancing Search Trees. Chapter 11

BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE. Sample Final Exam

Recall: Properties of B-Trees

Simulation in Computer Graphics Space Subdivision. Matthias Teschner

Multi-way Search Trees. (Multi-way Search Trees) Data Structures and Programming Spring / 25

Hidden Surface Elimination: BSP trees

Data Structures. Outline. Introduction Linked Lists Stacks Queues Trees Deitel & Associates, Inc. All rights reserved.

Intersection Acceleration

Advanced 3D-Data Structures

Ray Tracing Acceleration Data Structures

Collision Detection based on Spatial Partitioning

Identifying those parts of a scene that are visible from a chosen viewing position, and only process (scan convert) those parts

CS301 - Data Structures Glossary By

Ray Tracing III. Wen-Chieh (Steve) Lin National Chiao-Tung University

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu.

1. Meshes. D7013E Lecture 14

(2,4) Trees Goodrich, Tamassia (2,4) Trees 1

Name CPTR246 Spring '17 (100 total points) Exam 3

CS24 Week 8 Lecture 1

Binary Space Partition Trees. Overview. Binary Space Partitioning Trees (Fuchs, Kedem and Naylor `80)

Section 4 SOLUTION: AVL Trees & B-Trees

AVL Tree Definition. An example of an AVL tree where the heights are shown next to the nodes. Adelson-Velsky and Landis

Speeding Up Ray Tracing. Optimisations. Ray Tracing Acceleration

CIS265/ Trees Red-Black Trees. Some of the following material is from:

Page 1. Area-Subdivision Algorithms z-buffer Algorithm List Priority Algorithms BSP (Binary Space Partitioning Tree) Scan-line Algorithms

Computer Graphics II

9. Visible-Surface Detection Methods

Balanced Search Trees. CS 3110 Fall 2010

AVL Trees (10.2) AVL Trees

Solid Modeling. Thomas Funkhouser Princeton University C0S 426, Fall Represent solid interiors of objects

Spatial Data Structures and Speed-Up Techniques. Ulf Assarsson Department of Computer Science and Engineering Chalmers University of Technology

Data Structures Question Bank Multiple Choice

R16 SET - 1 '' ''' '' ''' Code No: R

CS Transform-and-Conquer

Lecture 7. Transform-and-Conquer

Hash Tables. CS 311 Data Structures and Algorithms Lecture Slides. Wednesday, April 22, Glenn G. Chappell

AVL Trees Goodrich, Tamassia, Goldwasser AVL Trees 1

(2,4) Trees. 2/22/2006 (2,4) Trees 1

CSC 172 Data Structures and Algorithms. Fall 2017 TuTh 3:25 pm 4:40 pm Aug 30- Dec 22 Hoyt Auditorium

The questions will be short answer, similar to the problems you have done on the homework

CSE 373 APRIL 17 TH TREE BALANCE AND AVL

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

INSTITUTE OF AERONAUTICAL ENGINEERING

Algorithms for Memory Hierarchies Lecture 2

Search Trees - 1 Venkatanatha Sarma Y

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?

Q1 Q2 Q3 Q4 Q5 Q6 Total

Space-based Partitioning Data Structures and their Algorithms. Jon Leonard

CSE Data Structures and Introduction to Algorithms... In Java! Instructor: Fei Wang. Mid-Term Exam. CSE2100 DS & Algorithms 1

Module 8: Range-Searching in Dictionaries for Points

Computer Graphics (CS 543) Lecture 13b Ray Tracing (Part 1) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

AVL Trees Heaps And Complexity

What is a Multi-way tree?

In-Memory Searching. Linear Search. Binary Search. Binary Search Tree. k-d Tree. Hashing. Hash Collisions. Collision Strategies.

CEng 477 Introduction to Computer Graphics Fall 2007

Analysis of Algorithms

Friday Four Square! 4:15PM, Outside Gates

CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL

Chapter 9. Priority Queue

Note that this is a rep invariant! The type system doesn t enforce this but you need it to be true. Should use repok to check in debug version.

CSC Design and Analysis of Algorithms

Prepared By: Ms. Nidhi Solanki (Assist. Prof.) Page 1

References and Homework ABSTRACT DATA TYPES; LISTS & TREES. Abstract Data Type (ADT) 9/24/14. ADT example: Set (bunch of different values)

9. Heap : Priority Queue

CS350: Data Structures AVL Trees

Sorted Arrays. Operation Access Search Selection Predecessor Successor Output (print) Insert Delete Extract-Min

CSC Design and Analysis of Algorithms. Lecture 7. Transform and Conquer I Algorithm Design Technique. Transform and Conquer

Data Structures and Algorithms

Transform & Conquer. Presorting

Copyright 1998 by Addison-Wesley Publishing Company 147. Chapter 15. Stacks and Queues

Global Rendering. Ingela Nyström 1. Effects needed for realism. The Rendering Equation. Local vs global rendering. Light-material interaction

Priority Queues. Binary Heaps

Scene Management. Video Game Technologies 11498: MSc in Computer Science and Engineering 11156: MSc in Game Design and Development

Trees. A tree is a directed graph with the property

Motivation for B-Trees

Visit ::: Original Website For Placement Papers. ::: Data Structure

CS535 Fall Department of Computer Science Purdue University

Geometric Algorithms. Geometric search: overview. 1D Range Search. 1D Range Search Implementations

Data Structure. A way to store and organize data in order to support efficient insertions, queries, searches, updates, and deletions.

Advanced Tree Data Structures

Section 5.3: Event List Management

MODELING AND HIERARCHY

Augmenting Data Structures

Transcription:

Data Structures and Algorithms

Data Structures static arrays if sorted, supports binary search (O(log n)) linked lists - dynamic size doubly-linked lists - easier deletion queues - FIFO stacks - LIFO dequeues - double-ended queue - push/pop either end maps - <key,value> with hash tables, O(1) search, insert, delete

Binary Search Trees each node holds a value, and has two subtrees all values in the left subtree are smaller than the parent's value all values in the right subtree are larger than the parent's value Search is O(log2 n) if tree balanced 5 4 8 3 6 9

AVL Tree binary search tree height of subtrees of any node differ by at most one (balanced) rebalance on insert/delete 5 3 5 insert 2 2 3 rebalance 2 3 5 balanced unbalanced balanced

Binary search tree == 1-D spatial index consider the number line 0 each tree node partitions the number line in two b 5 a b 5 a leaves correspond to convex regions (connected line segments) c 3 d 5 5 a c c 3 d d 5 e a f 3 7 3 5 7 c d e f

Searching a Binary Search Tree def search(tree, x): """returns leaf containing x""" if Tree.isLeaf(): return Tree elif x < Tree.value: return search(tree.leftchild, x ) else: return search (Tree.rightChild, x )

Binary Space Partitioning Tree A BSP tree is a binary search tree for N-D space Uses (N-1)-D linear splitting elements 2-D: lines line equation: ax + by + c = 0 Ax + c = 0 3-D: planes plane equation: ax + by + cz + d = 0 Nx + d = 0 (boldface used for vectors) N = normal to plane d = distance from origin if Nx + d < 0, x is "behind" the plane if Nx + d > 0, x is "in front of" the plane A N

Building a BSP Tree def buildbsp ( faces ): if len(faces) > 0: splitter = choosesplittingplane(faces) backfaces, infaces, frontfaces = split(faces,splitter) node = BSPTreeNode() node.plane = splitter node.polys = infaces node.leftchild = buildbsp(backfaces) node.rightchild = buildbsp(frontfaces) return node else: return BSPLeafNode()

Building a BSP Tree

Building a BSP Tree

Building a BSP Tree

Building a BSP Tree

Building a BSP Tree

Building a BSP Tree

Building a BSP Tree

Searching a BSP Tree Test if point x is "inside" or "outside" of the shape represented by a BSP Tree: def searchbsp ( Tree, x ): if Tree.isLeaf: return Tree.label dist = Tree.planeEquationAt(x) if dist > 0: return searchbsp ( Tree.rightChild, x) else: return searchbsp ( Tree.leftChild, x)

Rendering the Polygons in a BSP Tree draw the in-plane polygons in back-to-front (or front-to-back) order with respect to viewpoint a form of in-order traversal, where the order of visiting the subtrees depends on the the viewpoint's position with respect to the node's plane def renderbsp ( Tree, viewpoint ): if Tree.isLeaf: return dist = Tree.planeEquationAt(viewpoint) if dist > 0: nearsubtree = Tree.rightChild farsubtree = Tree.leftChild else: nearsubtree = Tree.leftChild farsubtree = Tree.rightChild renderbsp ( farsubtree ) drawpolygons ( Tree.polys ) renderbsp ( nearsubtree )

BSP Tree Summary BSP Trees can classify regions of space (eg as solid or empty) speeds up collision tests provide front-to-back or back-to-front orderings are "global" - any change requires rebuilding tree best for static elements

Quadtrees each level of the quadtree subdivides space into 4 square regions each region is recursively subdivided, as needed leaf nodes of quadtree correspond to regions terminate subdivision when a region is "simple enough" (eg, has < n objects)

no. items: 4 0 0 7

0 0 no. items: 3 1 0 0 3 4 0 0

Quadtrees 0 0 no. items: 3 1 0 0 3 0 0 0 1 2 2

http://groups.csail.mit.edu/graphics/classes/6.837/f98/talecture/

Octree "3-D quadtree" each non-leaf node has 8 children http://groups.csail.mit.edu/graphics/classes/6.837/f98/talecture/

http://www-evasion.imag.fr/membres/sylvain.lefebvre/pict1.png

Spatial Subdivision regular subdivision squares, cubes may have many empty regions easy to find in which region a point lies adaptive subdivision BSP Trees, quadtrees, octrees can be less verbose than regular subdivisions can cost more to search than regular subdivisions

Others tries - branching based on representation priority queue - find "largest" element in O(1) time graphs G = { N, E } N = nodes E = edges (n1, n2) C A O * T W A * L * L *