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

  • SEARCH
  • Home
  • 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 7071581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:42:19+00:00 2026-05-28T05:42:19+00:00

I have tree with the following node spec: java.util.TreeMap<Long id, java.util.TreeMap children> When I

  • 0

I have tree with the following node spec:

java.util.TreeMap<Long id, java.util.TreeMap children>

When I fill this map, I would like to retieve subtree only by id.

E.G.
Tree is:

     /-4
   /-2
1 <    /-5
   \-3<
       \-6

And when I’m using my code for ID=3, I would like to return only TreeMap with parentNode = 3

Thanks in advice

  • 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-05-28T05:42:20+00:00Added an answer on May 28, 2026 at 5:42 am

    You need search algorithm for trees. It’s easy with recursion. You should find all children in the root node and call the same method for each of them until you find node with ID you need and return it.
    Here and here you can find examples. Difference is that you’re using a map, but it doesn’t matter. Idea is the same.

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

Sidebar

Related Questions

I have a tree structure in memory that I would like to render in
lets say i have a tree of the following structure: <div>node level1 <div>node level2
I have the following tree: 1-[HAS]->2-[HASSUBPAGE]->3-[HASSUBPAGE]->4 Now I want to traverse this tree starting
I have a Tree class of the following type class Tree{ private: Node *root;
I have designed the following tree structure: function tree import javax.swing.* import javax.swing.tree.*; [I,map]
I have a Node Tree i like to iterate to find all ancestors until
I have to build a tree using the following data which comes from a
I have a complex html DOM tree of the following nature: <table> ... <tr>
I have the following problem: I am given a tree with N apples, for
In firefox, I have the following fragment in my .css file tree (negative){ font-size:

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.