Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7887881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:41:43+00:00 2026-06-03T05:41:43+00:00

I need to implement a B+ tree which is adapted to be a k

  • 0

I need to implement a B+ tree which is adapted to be a k-d tree. As a short
explanation of this, a k-d tree is like a binary tree except that at its
nodes it has a multi-valued key, that is a key with several values. And it will
also be a B+ tree cause the internal nodes are only meant to store 1 of the
values of the key and the real data is stored at the leaf nodes. Here’s a short
graphical explanation of it:

short graphical explanation

My leaf nodes have space for 2 elements, when I add the first 2 everything
works fine, till I add the third and I must make a split. For that, since I
choose the first value of the key to be the one that defines the order, I take
the median value of all three elements and the result is 27, so all elements
less than 27 go to the left and those bigger or equal than go to the right.

When I add the 4th element, since Tom and Linda have age less than 27 they
already completed a leaf node, son adding Dom makes the node to split again,
but this time I must switch which value of the key defines the order which is
Social Security Number. Again I take the median value and the result is 530, so
all those with SS Number less than 530 go to the left, and so on.

Resulting with the final k-d tree, with certain values of the key as index in
the internal nodes, and the complete key at the leaf nodes.

Now my question is, after explaining the context, how can I implement a
solution for the keys, given that I do have to store at the leaf nodes the
complete key, but at the internal nodes I only use one of the values of the
key.

You can notice the resemblance with a database, where we have multiple fields
with values, and we can sort the information with different fields at the same
time, one more important than the next and so on.

I thought of making a class named Key or any other name, with atributes that
hold all the values, for the above example, it could be int for age and int for
SSNumber and string for name. But my problem is, what if my client decides he
wants to add more values, then my class would grow bigger and bigger. Is this a
good OO decision? Can I implement this another way and still be OO? I know my
imagination can be poor, but since I can assume the client wants more values I
could make some sort of list that holds my values, then it means I would have
to make a list that can support any type of data, which doesn’t sound like an OO
approach. Any ideas?

Also I want to add that, since at some point of my algorithm of the tree ill
need to take 1 attribute of the key to use as the index in the tree, I must
support this as well.

I would really appreciate an idea of how to solve this by following an OO
approach.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:41:45+00:00Added an answer on June 3, 2026 at 5:41 am

    Make a Key an array of KeyPart, then each type of key value (age, ss#) can subclass from KeyPart. Then each internal node of your tree can store a single KeyPart and a key part index (to know what part it is the split of). The leaves can store the full Key.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write a binary tree to HDFS, which i will use to
I need to implement a server that can send Push Notifications to Android mobile
Here is my problem. I need to implement a multi target decision tree algorithm.
I have a JTree which I give objects that implement the TreeNode interface, and
My requirement is 1) I should construct a tree like the one which is
I need to traverse a binary tree, skipping the children of any node for
I need to implement a tree of decisions, very simple, not complicated in objective
I m trying to implement Tree Traversal PreOrder using yield return which returns an
I have a generic Tree class which will implement ICollection< T > (and hence
Grrrrrr, trying to implement a very simple tree. It doesn't need to be bidirectional

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.