Question

k-d tree Background One generalization of binary trees is the k-d tree, which stores k-dimensional data....

k-d tree

Background

One generalization of binary trees is the k-d tree, which stores k-dimensional data. Every internal node of a k-d tree indicates the dimension d and the value v in that dimension that it discriminates by. An internal node has exactly two children, containing data that is less-than-or-equal and data that is greater than v in dimension d. For example, if the node distinguishes on dimension 1, value 107, then the left child is for data with y value less than or equal to 107, and the right child is for data with y value greater than 107. Leaf nodes represent a bucket containing no more than b elements of k-dimensional data. All data are found in the leaves.

For this assignment, k is 4; that is, we only deal with four-dimensional data. Dimension numbers are therefore 0, 1, 2, and 3.

There are several strategies for building k-d trees. The offline method (1) accumulates all the data in an array, (2) finds the best dimension to discriminate on, namely, the one with the widest range, (3) finds the best value of that dimension to discriminate on, namely, the median value in that dimension (typically using the QuickSelect algorithm with Lomuto's partitioning method), (4) separates the data into two subarrays based on that discriminant, (5) recurses back to step 2 on each subarray. Recursion terminates when an array has size b or smaller. One can also devise online methods that add to existing trees.

Requirements

Write a program called kd that (1) takes a parameter n, which should be a positive integer, indicating how many data points are to be placed in the tree, and a parameter p, indicating the number of probes into the tree; (2) reads from standard input a list of n 4-dimensional integer data points; (3) builds a k-d tree with those n values using the offline method, with b set to 10 (and ties going to the left subtree); (4) reads p 4-dimensional data values, called probes, and for each probe, lists all the data points stored in the bucket where the probe would be found if it were in the tree.

In step 3, you may assume that all integer data are distinct.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

fast and secure web hosting at the lower possible price.

For ex: KD-tree is used in databases.

now you have the recoreds of employees like thier attributes .

query is to list the employees

age: 22 to 34

salary: $54,000 to $90,000

How will it  be done?

If data redundancy is not a problem for yo then you can sort the data separately, then do the range search with binary search to get the answers.

Data redundancy can be taken care by storing the original data in some hash map and storing the sorted list of indices.this will have the memory size.

If you really want the best memory and speed performance then KD-tree will be helpful.

Add a comment
Know the answer?
Add Answer to:
k-d tree Background One generalization of binary trees is the k-d tree, which stores k-dimensional data....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Tree Plot Please write a Java program to print or plot a binary tree in a 2-dimensional character format. You are not...

    Tree Plot Please write a Java program to print or plot a binary tree in a 2-dimensional character format. You are not allowed to use any existing Java classes such as ArrayList or Vector or Tree.    Your program must define 3 binary trees as follows. Each tree is defined in an integer 16 x 3 array. Programming Techniques: (1) The array for the binary tree can be integer data type with 16 rows by 3 columns. Please always make index...

  • Tree Plot Please write a Java program to print or plot a binary tree in a 2-dimensional character format. You are n...

    Tree Plot Please write a Java program to print or plot a binary tree in a 2-dimensional character format. You are not allowed to use any existing Java classes such as ArrayList or Vector or Tree.    Your program must define 3 binary trees as follows. Each tree is defined in an integer 16 x 3 array. Programming Techniques: (1) The array for the binary tree can be integer data type with 16 rows by 3 columns. Please always make index...

  • Trees Traversals Please write a Java program to traverse a binary tree in in-order and pre-order,...

    Trees Traversals Please write a Java program to traverse a binary tree in in-order and pre-order, and to plot a binary tree into a 2-dimensional array. You may write many recursive methods for this project. You are not allowed to use any existing Java classes such as ArrayList or Vector or Tree. Please stop your program if the user enters 0 as the tree selection. Your program must run the following Test Case 1 plus two more test cases to...

  • Trees Traversals Please write a Java program to traverse a binary tree in in-order and pre-order, and to plot a binar...

    Trees Traversals Please write a Java program to traverse a binary tree in in-order and pre-order, and to plot a binary tree into a 2-dimensional array. You may write many recursive methods for this project. You are not allowed to use any existing Java classes such as ArrayList or Vector or Tree. Please stop your program if the user enters 0 as the tree selection. Your program must run the following Test Case 1 plus two more test cases to...

  • Are my answers correct? Question 1 (Mandatory) (1 point) Saved Modern software systems are blurring the...

    Are my answers correct? Question 1 (Mandatory) (1 point) Saved Modern software systems are blurring the distinction between local files and web pages, which may be stored on a remote computer, so the amount of data that we might wish to search is virtually unlimited. Remarkably, the methods that we shall study can support search and insert operations on symbol tables containing trillions of items or more using only four or five references to small blocks of data. 1) True...

  • Preliminaries Download the template class and the driver file. Objective Learn how to traverse a binary...

    Preliminaries Download the template class and the driver file. Objective Learn how to traverse a binary search tree in order. Description For the template class BinarySearchTree, fill in the following methods: insert - Inserts values greater than the parent to the right, and values lesser than the parent to the left.parameters elem - The new element to be inserted into the tree. printInOrder - Prints the values stored in the tree in ascending order. Hint: Use a recursive method to...

  • C++ Binary Search Tree question. I heed help with the level 2 question please, as level...

    C++ Binary Search Tree question. I heed help with the level 2 question please, as level 1 is already completed. I will rate the answer a 100% thumbs up. I really appreciate the help!. Thank you! searching.cpp #include <getopt.h> #include <iostream> #include <sstream> #include <stdlib.h> #include <unistd.h> using namespace std; // global variable for tree operations // use to control tree maintenance operations enum Mode { simple, randomised, avl } mode; // tree type // returns size of tree //...

  • C++ Binary Search Tree question. I heed help with the level 2 question please, as level...

    C++ Binary Search Tree question. I heed help with the level 2 question please, as level 1 is already completed. I will rate the answer a 100% thumbs up. I really appreciate the help!. Thank you! searching.cpp #include <getopt.h> #include <iostream> #include <sstream> #include <stdlib.h> #include <unistd.h> using namespace std; // global variable for tree operations // use to control tree maintenance operations enum Mode { simple, randomised, avl } mode; // tree type // returns size of tree //...

  • please help!!!! JAVA I done the project expect one part but I still give you all...

    please help!!!! JAVA I done the project expect one part but I still give you all the detail that you needed... and I will post my code please help me fix the CreateGrid() part in main and make GUI works    List Type Data Structures Overview : You will be implementing my version of a linked list. This is a linked list which has possible sublists descending from each node. These sublists are used to group together all nodes which...

  • In this assignment you’ll implement a data structure called a trie, which is used to answer...

    In this assignment you’ll implement a data structure called a trie, which is used to answer queries regarding the characteristics of a text file (e.g., frequency of a given word). This write-up introduces the concept of a trie, specifies the API you’re expected to implement, and outlines submission instructions as well as the grading rubric. Please carefully read the entire write-up before you begin coding your submission. Tries A trie is an example of a tree data structure that compactly...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT