9 SPATIAL TREES Flashcards

1
Q

What is the primary focus of this chapter?

A

To improve nearest-neighbor searches using tree-based data structures and spatial partitioning.

The chapter builds on concepts from the previous chapter about finding specific values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the two new tree-based data structures introduced?

A
  • Uniform quadtrees
  • k-d trees
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the term ‘quadtree’ describe?

A

A class of two-dimensional data structures that partition each node into four subquadrants.

Based on the original quadtree proposed by Raphael Finkel and Jon Bentley.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a uniform quadtree?

A

A structure with equal-sized subregions that mirror the grid structure, proposed by David P. Anderson.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the main advantage of k-d trees over quadtrees?

A

K-d trees use a more flexible binary partitioning scheme that can adapt to the data and scale to higher dimensions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the main drawback of using grids for two-dimensional data?

A

They can either consume significant memory with finely grained grids or lead to inefficient searches with coarsely grained grids.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does a uniform quadtree partition space?

A

Each node is partitioned into four equal-sized quadrants, with a child node for each non-empty quadrant.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the labels commonly used for the four subtrees in a quadtree?

A
  • NorthWest
  • NorthEast
  • SouthWest
  • SouthEast
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What information do internal quadtree nodes store?

A
  • Pointers to up to four children
  • Metadata such as the number of points in the branch and spatial bounds
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a composite data structure for a QuadTreeNode?

A

QuadTreeNode {
* Boolean: is_leaf
* Integer: num_points
* Float: x_min
* Float: x_max
* Float: y_min
* Float: y_max
* Matrix of QuadTreeNodes: children
* Array of Points: points
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the purpose of storing spatial bounds in a quadtree node?

A

To simplify the implementation of search algorithms by allowing quick look-up of bounds instead of deriving them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does the power of quadtrees allow in terms of data structure?

A

It creates an adaptive, hierarchical grid through branching at each level.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What criteria can be used to decide when to stop subdividing a node in a quadtree?

A
  • Enough points to justify a split
  • Large enough spatial bounds
  • Maximum depth reached
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the typical process for building uniform quadtrees?

A

Recursively divide allocated space into smaller subregions while checking conditions to stop subdividing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What happens when adding points to a quadtree?

A

The tree is traversed to find the new point’s location, which may end at a leaf node or an internal dead end.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the QuadTreeInsert function do?

A

It ensures the point being inserted is within the quadtree’s bounds and calls QuadTreeNodeInsert.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does the code in QuadTreeNodeInsert function do?

A

It increments num_points, determines which child bin the point belongs to, and adds the point accordingly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the significance of checking splitting conditions when adding a point?

A

To determine whether to split the current leaf node into subnodes based on the number of points and spatial bounds.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What are the components of the Point structure in a quadtree?

A
  • Float: x
  • Float: y
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is the initial step when checking for a child in a quadtree?

A

Check whether the child exists; if not, create the child.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What values can xbin and ybin take in a quadtree?

A

Either 0 or 1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What happens at leaf nodes when inserting points into a quadtree?

A

Points are inserted directly into the node.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What condition must be checked before splitting a leaf node in a quadtree?

A

Whether the splitting conditions are met.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How does the code handle splitting a leaf node?

A

It marks the node as a non-leaf and reinserts the points one at a time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is the purpose of the FOR loop when reinserting points in a quadtree?
To reinsert points one at a time into the correct children.
26
What must be corrected to avoid double-counting points during reinsertion?
The num_points counter.
27
What is the first step in constructing a uniform quadtree?
Create an empty root node with the necessary spatial bounds.
28
What is the process for removing points from a quadtree?
Delete the point from the leaf node and recursively check for splits.
29
What is the challenge associated with deleting points from a quadtree?
Determining which point to delete, especially with close or duplicate points.
30
What helper function is used to find a point that is close enough for deletion?
approx_equal function.
31
What does the QuadTreeNodeCollapse function do?
Collapses a node with children and returns an array with all the subtree’s points.
32
What does the QuadTreeDelete function check before attempting to delete a point?
It checks that the point lies within the bounds of the tree.
33
What happens if the point to be deleted is found in a leaf node?
It removes the point from the list and decrements the count.
34
What does the recursive deletion function do if it finds a matching point?
Updates the count of points and checks whether the child is empty.
35
What is the purpose of the compatibility test in searching a quadtree?
To check whether the node could contain anything closer than the current candidate.
36
How is the distance from a search target to a node's bounding box computed?
Using the minimum distance formula for x and y coordinates.
37
What is the initial candidate point used in a nearest neighbor search?
A dummy candidate point with infinite distance.
38
Why do we start with a dummy candidate point in a nearest neighbor search?
To ensure any point found will be closer than infinitely far away.
39
What happens as we descend lower in a quadtree during a search?
The spatial bounds tighten.
40
What determines which child node to search first in a quadtree?
The proximity of the child nodes to the query point.
41
What occurs if a node could not contain a better neighbor during a search?
The node and its entire subtree are pruned from the search.
42
What is checked after finding a candidate nearest neighbor in a quadtree?
The compatibility of all remaining child quadrants.
43
What is the result of a successful pruning test in a nearest neighbor search?
The search can skip nodes that cannot contain a better neighbor.
44
What does the process of collapsing a node in a quadtree involve?
Aggregating points from each child and setting the node to be a leaf.
45
What does the pruning test confirm in a nearest-neighbor search?
The pruning test confirms that a quadrant could contain a closer neighbor than the current best point ## Footnote This is illustrated in Figure 9-1.
46
What happens when a child node could contain a closer point during the nearest-neighbor search?
The search proceeds down that pathway to check for closer neighbors.
47
What are the four potential quadrants that vie for attention in a nearest-neighbor search?
NorthWest, NorthEast, SouthWest, SouthEast.
48
Which quadrants can be skipped during the search in a nearest-neighbor algorithm?
The NorthEast and SouthWest quadrants if they are empty, and SouthEast if it's too far away.
49
What is the purpose of the MinDist function in the nearest-neighbor search?
To compute the distance from the target point (x, y) to a node.
50
What does the best_dist parameter represent in the nearest-neighbor search algorithm?
The distance so far.
51
What does a return value of null indicate in the nearest-neighbor search?
There are no points in the current node closer than best_dist.
52
What is the initial distance passed to the nearest-neighbor search wrapper function?
Infinite distance.
53
How are points stored in a KDTreeNode structure?
As an array of Floats.
54
What is the main advantage of a k-d tree over a quadtree?
It allows for flexible partitioning along a single dimension.
55
What does each internal node in a k-d tree store?
The dimension along which it's partitioning (split_dim) and the split value (split_val).
56
What is the structure of a KDTree?
It contains the number of dimensions and a root KDTreeNode.
57
What is a key characteristic of the k-d tree's partitioning method?
It can choose the best split dimension and value based on the data composition.
58
What is the benefit of tracking the bounding box of points in a spatial tree?
It improves the tree's pruning power.
59
What is the problem with using octrees for three-dimensional data?
It doesn't scale gracefully with the number of dimensions.
60
True or False: The k-d tree can split along every dimension at every level.
False.
61
Fill in the blank: A k-d tree combines the spatial partitioning of ______ with the binary branching factor of a binary search tree.
quadtrees.
62
What does the flexible structure of the k-d tree allow for?
More effective searches by tailoring splits based on data composition.
63
In the context of a k-d tree, what does the term 'split_dim' refer to?
The dimension along which the node is partitioned.
64
What is an example of a scenario where k-d trees are more efficient than quadtrees?
Searching for similar conditions in higher-dimensional datasets.
65
What is the primary purpose of choosing the widest dimension in city planning?
To minimize long, narrow zones.
66
What does a median point provide in a spatial tree?
A balanced tree.
67
How can the pruning power of a spatial tree be improved?
By tracking the bounding box of all points within a node.
68
What is the difference in the pruning question when using bounding boxes?
It changes from 'Could a nearest-neighbor candidate exist in the space covered by the node?' to 'Could a nearest-neighbor candidate exist in the bounding boxes of actual points within the node?'
69
What is the benefit of using tighter bounding boxes during node construction?
It allows better adaptation to the data.
70
What do tight bounding boxes allow during search operations?
More aggressive pruning.
71
What is the function of ComputeBoundingBox?
To compute the tight bounding box of the points in a node.
72
What does the RecursiveBuildKDTree function do?
It recursively builds the k-d tree.
73
What are the termination criteria for building a k-d tree?
* Minimum number of points left at the node * Minimum width * Maximum depth
74
What must be checked before building a k-d tree?
That all points have the correct dimensionality.
75
What is a major difference in k-d tree construction compared to quadtree construction?
K-d trees require choosing a single split dimension at each level.
76
What happens if the conditions to split a node are not met in k-d tree construction?
All remaining points are stored in a list at the leaf.
77
What is the advantage of bulk construction of k-d trees?
It allows better adaptation of the tree structure to the data.
78
What operations are performed on a k-d tree?
* Inserting points * Deleting points * Searching
79
How do we determine which branch to take when inserting points into a k-d tree?
Using split_dim and split_val.
80
What is the process for updating the bounding box when inserting a point?
Check each dimension of the new point against the current bounds and update if necessary.
81
What is the key difference in search operations between a quadtree and a k-d tree?
How nodes can be pruned based on the Euclidean distance from a query point.
82
What can cause k-d trees to become unbalanced?
Additions and deletions of points.
83
What do quadtrees allow us to do in terms of data density?
Adapt the resolution of a grid to the density of data points.
84
How does a k-d tree solve the problem of a high branching factor?
By choosing a single dimension along which to split at each node.
85
What tradeoffs are associated with different spatial data structures?
* Program complexity * Computational cost * Memory usage
86
What does the code for building a k-d tree include?
Bookkeeping to fill in essential details at each node.
87
What indicates that a k-d tree node is a leaf?
The is_leaf attribute being True.
88
What does the term 'minimum distance' refer to in k-d trees?
The distance from a query point to the closest possible point in a node's bounding box.